Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CT 1604 remove compiled classes #6384

Merged
merged 11 commits into from
Dec 7, 2022
Merged

Conversation

gshank
Copy link
Contributor

@gshank gshank commented Dec 5, 2022

resolves #6383

Description

Remove compiled classes in order to simplify the artifact generation and code.

Checklist

@gshank gshank requested a review from a team as a code owner December 5, 2022 21:48
@gshank gshank requested a review from a team December 5, 2022 21:48
@gshank gshank requested review from a team as code owners December 5, 2022 21:48
@cla-bot cla-bot bot added the cla:yes label Dec 5, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2022

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

1 similar comment
@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2022

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

@gshank gshank marked this pull request as draft December 5, 2022 22:23
@gshank
Copy link
Contributor Author

gshank commented Dec 6, 2022

I renamed the core/dbt/contracts/graph/parsed.py file to core/dbt/contracts/graph/nodes.py

I've renamed the main "Parsed" classes: ParsedModelNode, ParsedAnalysisNode, ParsedSeedNode, ParsedSqlNode, ParsedGenericTestNode, ParsedSingularTestNode, ParsedHookNode, ParsedSeedNode, ParsedSnapshotNode, ParsedSourceDefinition, ParsedMetric, ParsedExposure and ParsedMacro to ModelNode, AnalysisNode, SeedNode, SqlNode, GenericTestNode, SingularTestNode, HookNode, SeedNode, SnapshotNode, SourceDefinition, Exposure, Metric and Macro.

I left ParsedNode alone (opinions?). Changed ParsedTestNode to TestNode, ParsedResource to Resource. Had to move a few Unions from the former compiled.py file to nodes.py

I'm planning to try to make a parsed.py file for compatibility with the old names to see if we can avoid some adapter updates, otherwise this will require that various adapter tests be modified. Might need to do that anyway...

@gshank
Copy link
Contributor Author

gshank commented Dec 6, 2022

@cla-bot check

@cla-bot
Copy link

cla-bot bot commented Dec 6, 2022

The cla-bot has been summoned, and re-checked this pull request!

Copy link
Contributor

@jtcohen6 jtcohen6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very satisfying to see this cleanup underway. Appreciate the thought given to back-compat for plugins (adapters, and dbt-rpc as well). Let's see what we can do — and if we can't, we'll very call out the required upgrade paths.

@@ -0,0 +1,7 @@
kind: Under the Hood
body: Remove compiled node classes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels more like "unify" or "consolidate" ParsedNode + CompiledNode classes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. Will change wording.

@@ -32,7 +32,7 @@ class RemoteResult(VersionedSchema):
class RemoteCompileResultMixin(RemoteResult):
raw_code: str
compiled_code: str
node: CompileResultNode
node: ResultNode
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may have implications for dbt-rpc (here). I don't think this should have any direct implications for dbt-server / lib.py, but worth testing to be sure.

compiled_code: Optional[str] = None
extra_ctes_injected: bool = False
extra_ctes: List[InjectedCTE] = field(default_factory=list)
relation_name: Optional[str] = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels weird and incorrect that relation_name is only available during compilation, rather than after parsing. I think the reason had been, we need to know the adapter's quoting config — but I'm pretty sure we'd be able to know that at parse time too, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so. I agree that it would be nice to have this available at parse time. I think "relation_name" was added by an external contributor, so I'm guessing it was at compile time because it was easier to find a place to put it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do set "relation_name" for SourceDefinition at parse time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll look at setting relation_name in the right place in the pull request to implement the nodes in protobuf messages.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're right! Sounds good.

@gshank
Copy link
Contributor Author

gshank commented Dec 7, 2022

I checked the adapter repos and the only imports from a changed file are for a tests/unit/utils.py file in methods which are not actually used anywhere, so it doesn't look like the CI tests should fail. Those repos should be updated to remove the dead code though, so I'll open tickets to do that after this is merged.

I don't see any imports in dbt-server from dbt.contracts.graph, so I think we're good there.

dbt-rpc will have to be updated. I'll open a ticket to do that after this is merged.

@gshank gshank marked this pull request as ready for review December 7, 2022 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CT-1604] Remove Compiled Node classes
4 participants