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): add include_table_location_lineage flag for SQL common #6934

Merged
merged 2 commits into from
Jan 4, 2023
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
2 changes: 2 additions & 0 deletions metadata-ingestion/src/datahub/ingestion/source/sql/athena.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,13 @@ def get_sql_alchemy_url(self):
SourceCapability.DATA_PROFILING,
"Optionally enabled via configuration. Profiling uses sql queries on whole table which can be expensive operation.",
)
@capability(SourceCapability.LINEAGE_COARSE, "Supported for S3 tables")
@capability(SourceCapability.DESCRIPTIONS, "Enabled by default")
class AthenaSource(SQLAlchemySource):
"""
This plugin supports extracting the following metadata from Athena
- Tables, schemas etc.
- Lineage for S3 tables.
- Profiling when enabled.
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def get_table_properties(
) -> Tuple[Optional[str], Dict[str, str], Optional[str]]:
description, properties, location_urn = super().get_table_properties(
inspector, schema, table
) # type:Tuple[Optional[str], Dict[str, str], Optional[str]]
)
# Update description if available.
db_name: str = self.get_db_name(inspector)
description = self.table_descriptions.get(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ class SQLAlchemyConfig(StatefulIngestionConfigBase):
default=True, description="Whether tables should be ingested."
)

include_table_location_lineage: bool = Field(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do any other sources need to have the capability listed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Athena is the only source that generates lineage in this way

default=True,
description="If the source supports it, include table lineage to the underlying storage location.",
)

profiling: GEProfilingConfig = GEProfilingConfig()
# Custom Stateful Ingestion settings
stateful_ingestion: Optional[StatefulStaleMetadataRemovalConfig] = None
Expand Down Expand Up @@ -841,7 +846,7 @@ def _process_table(
)
dataset_snapshot.aspects.append(dataset_properties)

if location_urn:
if self.config.include_table_location_lineage and location_urn:
external_upstream_table = UpstreamClass(
dataset=location_urn,
type=DatasetLineageTypeClass.COPY,
Expand Down