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): schema-aware SQL parsing for column-level lineage #8334

Merged
merged 39 commits into from
Jul 7, 2023

Conversation

hsheth2
Copy link
Collaborator

@hsheth2 hsheth2 commented Jun 28, 2023

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 Jun 28, 2023
@hsheth2 hsheth2 marked this pull request as ready for review June 29, 2023 19:55
Copy link
Collaborator

@asikowitz asikowitz left a comment

Choose a reason for hiding this comment

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

Haven't been able to go through this whole thing but looks good to me so far. I have a couple questions but nothing serious. I feel like there should be a cleaner way to do the -> urn conversion but haven't really thought about it, the "duplicate" classes _ColumnRef and ColumnRef just rubbing me the wrong way. Going to approve in case you need to merge, will finish review much later tonight

@@ -285,6 +295,7 @@ def get_long_description():
| bigquery_common
| {
*sqllineage_lib,
*sqlglot_lib,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be nice to get rid of bigquery beta if we can

column_error: Optional[Exception]


class SqlParsingResult(BaseModel):
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the difference between using pydantic here vs dataclasses? Mostly curious

default_schema: Optional[str] = None,
) -> SqlParsingResult:
# TODO: convert datahub platform names to sqlglot dialect
dialect = platform
Copy link
Collaborator

Choose a reason for hiding this comment

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

Mostly unrelated to this PR, but we should make a platform enum

Copy link
Collaborator

@asikowitz asikowitz left a comment

Choose a reason for hiding this comment

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

Haven't been able to go through this whole thing but looks good to me so far. I have a couple questions but nothing serious. I feel like there should be a cleaner way to do the -> urn conversion but haven't really thought about it, the "duplicate" classes _ColumnRef and ColumnRef just rubbing me the wrong way. Going to approve in case you need to merge, will finish review much later tonight

@hsheth2
Copy link
Collaborator Author

hsheth2 commented Jul 7, 2023

@asikowitz going to merge here and fix in a follow up: #8382

@hsheth2 hsheth2 merged commit 3e47b3d into datahub-project:master Jul 7, 2023
@hsheth2 hsheth2 deleted the sqlglot branch July 7, 2023 23:24
Comment on lines +247 to +249
self._schema_cache: FileBackedDict[Optional[SchemaInfo]] = FileBackedDict(
shared_connection=shared_conn,
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Doesn't look like we ever close this, are we just relying on garbage collection for that? I could see that taking a while because references may be kept in memory by the lru_cache

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed in the follow up by explicitly calling self._make_schema_resolver.cache_clear()

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants