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

feat(ingest/snowflake): support lineage via rename and swap using que… #11600

Merged
merged 9 commits into from
Oct 23, 2024

Conversation

mayurinehate
Copy link
Collaborator

…ries v2

Checklist

  • The PR conforms to DataHub's Contributing Guideline (particularly Commit Message Format)
  • Links to related issues (if applicable)
  • Tests for the changes have been added/updated (if applicable)
  • Docs related to the changes have been added/updated (if applicable). If a new feature has been added a Usage Guide has been added for the same.
  • For any breaking change/potential downtime/deprecation/big changes an entry has been made in Updating DataHub

@github-actions github-actions bot added the ingestion PR or Issue related to the ingestion of metadata label Oct 11, 2024
FROM deduplicated_queries q
JOIN filtered_access_history a USING (query_id)
-- This qualify ignores more than 1 rows from same query, such as for ddl swap
QUALIFY
ROW_NUMBER() OVER (PARTITION BY query_id ORDER BY start_time DESC) = 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

we have the deduplicated_queries cte - should we push stuff down to that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is for after join with access_history. Table access_history may have more than one row for same query

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As we are now ignoring duplicate swaps, we can in fact remove this qualify as it is fine to process same swap query multiple times.

"aspect": {
"json": {
"statement": {
"value": "CREATE TABLE foo_staging AS\nSELECT\n f.a,\n d.b\nFROM foo AS f\nJOIN foo_dep AS d\n USING (c);\n\nCREATE TABLE foo_backup AS\nSELECT\n *\nFROM foo_staging",
Copy link
Collaborator

Choose a reason for hiding this comment

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

probably would be tricky to do, but it'd be super cool if the swap statement would show up in the composite query

@@ -185,6 +185,10 @@ class TableSwap:
urn1: UrnStr
urn2: UrnStr

def id(self) -> str:
# TableSwap(A,B) is same as TableSwap(B,A)
return str(hash(frozenset([self.urn1, self.urn2])))
Copy link
Collaborator

Choose a reason for hiding this comment

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

we can do dataclasses.dataclass(frozen=True) to make it hashable

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did try that earlier but it does not ignore the order of urns. Having array instead of individual fields would work but then we would need to ensure somehow that array has only two entries. Also might make code less readable, so keeping this as is.

Copy link
Collaborator

@hsheth2 hsheth2 left a comment

Choose a reason for hiding this comment

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

I didn't look at the tests super closely, but this seems reasonable

@mayurinehate mayurinehate added the merge-pending-ci A PR that has passed review and should be merged once CI is green. label Oct 22, 2024
@anshbansal anshbansal merged commit eab2ac7 into datahub-project:master Oct 23, 2024
73 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ingestion PR or Issue related to the ingestion of metadata merge-pending-ci A PR that has passed review and should be merged once CI is green.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants