-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
feat(ingest/snowflake): allow shares config without platform instance #8803
Merged
anshbansal
merged 10 commits into
datahub-project:master
from
mayurinehate:master+ing-303-snowflake-share-no-platform-instance
Sep 25, 2023
Merged
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7caefaf
feat(ingest/snowflake): allow shares config without platform instance
mayurinehate c43ed5f
Merge branch 'master' into master+ing-303-snowflake-share-no-platform…
mayurinehate 5f6dfda
fix lint
mayurinehate a58aff1
Update snowflake_config.py
mayurinehate 386b79f
Merge branch 'master' into master+ing-303-snowflake-share-no-platform…
mayurinehate 7c5f8e0
fix lint
mayurinehate 836f324
Merge branch 'master' into master+ing-303-snowflake-share-no-platform…
mayurinehate 10c35fd
Merge branch 'master' into master+ing-303-snowflake-share-no-platform…
asikowitz 466d499
Merge branch 'master' into master+ing-303-snowflake-share-no-platform…
mayurinehate d656524
Merge branch 'master' into master+ing-303-snowflake-share-no-platform…
mayurinehate 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -231,6 +231,7 @@ def test_snowflake_shares_workunit_inbound_share( | |
else: | ||
siblings_aspect = wu.get_aspect_of_type(Siblings) | ||
assert siblings_aspect is not None | ||
assert not siblings_aspect.primary | ||
assert len(siblings_aspect.siblings) == 1 | ||
assert siblings_aspect.siblings == [ | ||
wu.get_urn().replace("instance1.db1", "instance2.db1") | ||
|
@@ -275,6 +276,7 @@ def test_snowflake_shares_workunit_outbound_share( | |
for wu in wus: | ||
siblings_aspect = wu.get_aspect_of_type(Siblings) | ||
assert siblings_aspect is not None | ||
assert siblings_aspect.primary | ||
assert len(siblings_aspect.siblings) == 2 | ||
assert siblings_aspect.siblings == [ | ||
wu.get_urn().replace("instance1.db2", "instance2.db2_from_share"), | ||
|
@@ -336,13 +338,85 @@ def test_snowflake_shares_workunit_inbound_and_outbound_share( | |
siblings_aspect = wu.get_aspect_of_type(Siblings) | ||
assert siblings_aspect is not None | ||
if "db1" in wu.get_urn(): | ||
assert not siblings_aspect.primary | ||
assert len(siblings_aspect.siblings) == 1 | ||
assert siblings_aspect.siblings == [ | ||
wu.get_urn().replace("instance1.db1", "instance2.db1") | ||
] | ||
else: | ||
assert siblings_aspect.primary | ||
assert len(siblings_aspect.siblings) == 2 | ||
assert siblings_aspect.siblings == [ | ||
wu.get_urn().replace("instance1.db2", "instance2.db2_from_share"), | ||
wu.get_urn().replace("instance1.db2", "instance3.db2"), | ||
] | ||
|
||
|
||
def test_snowflake_shares_workunit_inbound_and_outbound_share_no_platform_instance( | ||
snowflake_databases: List[SnowflakeDatabase], | ||
) -> None: | ||
config = SnowflakeV2Config( | ||
account_id="abc12345", | ||
shares={ | ||
"share1": SnowflakeShareConfig( | ||
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. "db1" (primary, included in share) and "db2"(secondary, created from share) are present in this account, as present in |
||
database="db1", | ||
consumers=[ | ||
DatabaseId(database="db1_from_share"), | ||
DatabaseId(database="db1_other"), | ||
], | ||
), | ||
"share2": SnowflakeShareConfig( | ||
database="db2_main", | ||
consumers=[ | ||
DatabaseId(database="db2"), | ||
DatabaseId(database="db2_other"), | ||
], | ||
), | ||
}, | ||
) | ||
|
||
report = SnowflakeV2Report() | ||
shares_handler = SnowflakeSharesHandler( | ||
config, report, lambda x: make_snowflake_urn(x) | ||
) | ||
|
||
assert sorted(config.outbounds().keys()) == ["db1", "db2_main"] | ||
assert sorted(config.inbounds().keys()) == [ | ||
"db1_from_share", | ||
"db1_other", | ||
"db2", | ||
"db2_other", | ||
] | ||
wus = list(shares_handler.get_shares_workunits(snowflake_databases)) | ||
|
||
# 6 Sibling aspects for db1 tables | ||
# 6 Sibling aspects and and 6 upstreamLineage for db2 tables | ||
assert len(wus) == 18 | ||
|
||
for wu in wus: | ||
assert isinstance( | ||
wu.metadata, (MetadataChangeProposal, MetadataChangeProposalWrapper) | ||
) | ||
if wu.metadata.aspectName == "upstreamLineage": | ||
upstream_aspect = wu.get_aspect_of_type(UpstreamLineage) | ||
assert upstream_aspect is not None | ||
assert len(upstream_aspect.upstreams) == 1 | ||
assert upstream_aspect.upstreams[0].dataset == wu.get_urn().replace( | ||
"db2.", "db2_main." | ||
) | ||
else: | ||
siblings_aspect = wu.get_aspect_of_type(Siblings) | ||
assert siblings_aspect is not None | ||
if "db1" in wu.get_urn(): | ||
assert siblings_aspect.primary | ||
assert len(siblings_aspect.siblings) == 2 | ||
assert siblings_aspect.siblings == [ | ||
wu.get_urn().replace("db1.", "db1_from_share."), | ||
wu.get_urn().replace("db1.", "db1_other."), | ||
] | ||
else: | ||
assert not siblings_aspect.primary | ||
assert len(siblings_aspect.siblings) == 1 | ||
assert siblings_aspect.siblings == [ | ||
wu.get_urn().replace("db2.", "db2_main.") | ||
] |
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.
I'd make this an INFO, and perhaps explain what setting platform instance provides (i.e. no conflict for entities with the same name in each instance). I think there are valid use cases for not setting platform instance, e.g. you don't expect overlap or you're looking at different slices of the same data
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.
done