Skip to content
Merged
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 @@ -72,6 +72,8 @@ class QueryLogSetting(enum.Enum):
_DEFAULT_QUERY_LOG_SETTING = QueryLogSetting[
os.getenv("DATAHUB_SQL_AGG_QUERY_LOG") or QueryLogSetting.DISABLED.name
]
MAX_UPSTREAM_TABLES_COUNT = 300
MAX_FINEGRAINEDLINEAGE_COUNT = 2000


@dataclasses.dataclass
Expand Down Expand Up @@ -229,6 +231,8 @@ class SqlAggregatorReport(Report):
num_unique_query_fingerprints: Optional[int] = None
num_urns_with_lineage: Optional[int] = None
num_lineage_skipped_due_to_filters: int = 0
num_table_lineage_trimmed_due_to_large_size: int = 0
num_column_lineage_trimmed_due_to_large_size: int = 0

# Queries.
num_queries_entities_generated: int = 0
Expand Down Expand Up @@ -1154,6 +1158,26 @@ def _gen_lineage_for_downstream(
confidenceScore=queries_map[query_id].confidence_score,
)
)

if len(upstream_aspect.upstreams) > MAX_UPSTREAM_TABLES_COUNT:
logger.warning(
f"Too many upstream tables for {downstream_urn}: {len(upstream_aspect.upstreams)}"
f"Keeping only {MAX_UPSTREAM_TABLES_COUNT} table level upstreams/"
)
upstream_aspect.upstreams = upstream_aspect.upstreams[
:MAX_UPSTREAM_TABLES_COUNT
]
self.report.num_table_lineage_trimmed_due_to_large_size += 1
if len(upstream_aspect.fineGrainedLineages) > MAX_FINEGRAINEDLINEAGE_COUNT:
logger.warning(
Copy link
Contributor

Choose a reason for hiding this comment

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

would be good to add some counters to the report for these

f"Too many upstream columns for {downstream_urn}: {len(upstream_aspect.fineGrainedLineages)}"
f"Keeping only {MAX_FINEGRAINEDLINEAGE_COUNT} column level upstreams/"
)
upstream_aspect.fineGrainedLineages = upstream_aspect.fineGrainedLineages[
:MAX_FINEGRAINEDLINEAGE_COUNT
]
self.report.num_column_lineage_trimmed_due_to_large_size += 1

upstream_aspect.fineGrainedLineages = (
upstream_aspect.fineGrainedLineages or None
)
Expand Down