-
Notifications
You must be signed in to change notification settings - Fork 92
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
Migrate to dbt-common + dbt-adapters #342
Merged
jwills
merged 20 commits into
duckdb:master
from
jtcohen6:jerco/migrate-dbt-common-adapters-interfaces
May 8, 2024
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
1e25859
Migrate to dbt-common + dbt-adapters
jtcohen6 86eface
Try different install reqs
jtcohen6 2d36968
Fix unit tests
jtcohen6 3ad787e
Bonus: functional tests for dbt unit testing
jtcohen6 d4d5939
bump dbt-common and dbt-adapters to 1.0.0b1
MichelleArk 10034b3
Merge branch 'master' into jerco/migrate-dbt-common-adapters-interfaces
MichelleArk 5712711
implement DuckDbRelation.create_from, fix TestExternalSources::test_e…
MichelleArk af5f989
Merge branch 'master' into jerco/migrate-dbt-common-adapters-interfaces
MichelleArk 9c8113a
use RelationConfig attributes in create_from_source
MichelleArk 80b709d
Merge branch 'master' into jerco/migrate-dbt-common-adapters-interfaces
MichelleArk b8fdca0
formatting + initial mypy fixes
MichelleArk 6527752
Merge branch 'master' into jerco/migrate-dbt-common-adapters-interfaces
jtcohen6 9a0ba02
Revert dev-requirements
jtcohen6 6dcc39c
Readd dbt-tests-adapter
jtcohen6 5f594c4
Readd dbt-core to setup.py for install back-compat
jtcohen6 8511b94
Merge branch 'master' into jerco/migrate-dbt-common-adapters-interfaces
jtcohen6 0750e0c
Merge remote-tracking branch 'origin/master' into jerco/migrate-dbt-c…
jtcohen6 a85cef9
Skip BV for TestUnitTestingTypesDuckDB
jtcohen6 298f27c
Merge branch 'master' into jerco/migrate-dbt-common-adapters-interfaces
jwills 08d5530
Merge branch 'master' into jerco/migrate-dbt-common-adapters-interfaces
jwills File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Migrate to dbt-common + dbt-adapters
- Loading branch information
commit 1e258597525a6b74338c65bd937174ab996c25fa
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,9 @@ | |
|
||
from dbt.adapters.base.column import Column | ||
from dbt.adapters.base.relation import BaseRelation | ||
from dbt.context.providers import RuntimeConfigObject | ||
from dbt.contracts.graph.nodes import SourceDefinition | ||
# TODO | ||
# from dbt.context.providers import RuntimeConfigObject | ||
# from dbt_common.contracts.graph.nodes import SourceDefinition | ||
|
||
|
||
@dataclass | ||
|
@@ -47,7 +48,7 @@ def as_dict(self) -> Dict[str, Any]: | |
return base | ||
|
||
@classmethod | ||
def create_from_source(cls, source: SourceDefinition) -> "SourceConfig": | ||
def create_from_source(cls, source: Any) -> "SourceConfig": | ||
meta = source.source_meta.copy() | ||
meta.update(source.meta) | ||
# Use the config properties as well if they are present | ||
|
@@ -75,7 +76,7 @@ def as_dict(self) -> Dict[str, Any]: | |
class TargetConfig: | ||
relation: BaseRelation | ||
column_list: Sequence[Column] | ||
config: RuntimeConfigObject | ||
config: Any # TODO | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is probably the safest since our usage of this config object is pretty much limited to |
||
location: Optional[TargetLocation] = None | ||
|
||
def as_dict(self) -> Dict[str, Any]: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Losing the
SourceDefinition
typing makes me a bit more nervous since we rely on its fields pretty extensively and theexternal_location
features are a pretty popular part of dbt-duckdb on top of simple data lakes or just CSV/Parquet files on a NASThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heard - let me bug @MichelleArk & @colin-rogers-dbt about this and get back to you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As part of the decoupling work, we removed the
BaseRelation.create_from_source
andBaseRelation.create_from_node
methods in favor of a consolidatedBaseRelation.create_from
method that acceptsquoting: HasQuoting
andrelation_config: RelationConfig
(dbt-labs/dbt-core#9210). I've updated this branch to reflect that typing + implementedDuckDBRelation.create_from
here: 5712711.We should also extend the
RelationConfig
to also providemeta
andtags
, as well asresource_type
so this kind of conditional logic can still be implemented reliably for sources in dbt-adapters: https://github.com/dbt-labs/dbt-adapters/pull/120/files.Still need to figure out how we want to handle
source_meta
, since its not a common property across sources + other node types. I see at a few options:create_from_source
method to usehasattr
or something similarly unsatisfyingmerged_meta
attribute on sources + nodes in dbt-core and extendRelationConfig
to expectmerged_meta
, which the duckdb adapter could use instead of accessingsource_meta
+ merging. This doesn't feel like the slickest interface design and would need changes to most of our node classes in core but it'd get the job done.meta
field onSourceDefinition
to include fields fromsource_meta
by default, meaning the duckdb adapter wouldn't need to do theupdate
business at all. It might be tricky to do this in a backward-compatible way in dbt-core though.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MichelleArk thank you for this, I really appreciate it. Will try to noodle on a good strategy here, but using the
hasattr
stuff as an ugly-but-necessary fallback is okay with me if we don't find something better.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went ahead with option 3 above in dbt-core: dbt-labs/dbt-core#9766, since it was actually pretty straightforward to do in a backward-compatible way (meta merges table.meta and source.meta, with table.meta taking precedence), and updated the branch to remove the
source_meta
reference in favor of justmeta
which now includes both table + source meta attributes.I also updated the reference to
config._extra
toconfig.extra
, as those should be identical andextra
is already part of the RelationConfig protocol: https://github.com/dbt-labs/dbt-adapters/blob/35bd3629c390cf87a0e52d999679cc5e33f36c8f/dbt/adapters/contracts/relation.py#L41.Tests were passing for me locally against dbt-core@main. @jwills -- could we kick off CI again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great @MichelleArk , thank you!