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

fix(ingest): fix missing snowflake lineage when table_pattern is set #6410

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,12 @@ class SnowflakeUpstreamTable:
downstreamColumns: List[SnowflakeColumnWithLineage]

@classmethod
def from_dict(cls, dataset, upstreams_columns_json, downstream_columns_json):
def from_dict(
cls,
dataset: str,
upstreams_columns_json: Optional[str],
downstream_columns_json: Optional[str],
) -> "SnowflakeUpstreamTable":
try:
upstreams_columns_list = []
downstream_columns_list = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from datahub.metadata.schema_classes import _Aspect


# Required only for mypy, since we are using mixin classes, and not inheritance.
# Reference - https://mypy.readthedocs.io/en/latest/more_types.html#mixin-classes
class SnowflakeLoggingProtocol(Protocol):
@property
def logger(self) -> logging.Logger:
Expand All @@ -37,6 +39,9 @@ def get_dataset_identifier(
) -> str:
...

def get_dataset_identifier_from_qualified_name(self, qualified_name: str) -> str:
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this have any implementation or why it is just ...?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hey, this Protocol class is only for mypy. This is required if using mixin classes, without actually doing inheritance. Reference - https://mypy.readthedocs.io/en/latest/more_types.html#mixin-classes

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add this comment in the code as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

...

def snowflake_identifier(self, identifier: str) -> str:
...

Expand Down Expand Up @@ -76,14 +81,16 @@ def _is_dataset_pattern_allowed(
return False

if dataset_type.lower() in {"table"} and not self.config.table_pattern.allowed(
dataset_params[2].strip('"')
self.get_dataset_identifier_from_qualified_name(dataset_name)
):
return False

if dataset_type.lower() in {
"view",
"materialized_view",
} and not self.config.view_pattern.allowed(dataset_params[2].strip('"')):
} and not self.config.view_pattern.allowed(
self.get_dataset_identifier_from_qualified_name(dataset_name)
):
return False

return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from freezegun import freeze_time

from datahub.configuration.common import DynamicTypedConfig
from datahub.configuration.common import AllowDenyPattern, DynamicTypedConfig
from datahub.ingestion.run.pipeline import Pipeline
from datahub.ingestion.run.pipeline_config import PipelineConfig, SourceConfig
from datahub.ingestion.source.snowflake import snowflake_query
Expand Down Expand Up @@ -297,6 +297,7 @@ def test_snowflake_basic(pytestconfig, tmp_path, mock_time, mock_datahub_graph):
username="TST_USR",
password="TST_PWD",
include_views=False,
table_pattern=AllowDenyPattern(allow=["test_db.test_schema.*"]),
include_technical_schema=True,
include_table_lineage=True,
include_view_lineage=False,
Expand Down