Skip to content

Commit

Permalink
fix(ingest/snowflake): use fast query fingerprint for lineage (#12275)
Browse files Browse the repository at this point in the history
  • Loading branch information
mayurinehate authored Jan 6, 2025
1 parent 842c8f9 commit 91c1c6b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
ColumnRef,
DownstreamColumnRef,
)
from datahub.sql_parsing.sqlglot_utils import get_query_fingerprint
from datahub.utilities.perf_timer import PerfTimer
from datahub.utilities.time import ts_millis_to_datetime

Expand Down Expand Up @@ -239,6 +240,9 @@ def get_known_query_lineage(
downstream_table_urn = self.identifiers.gen_dataset_urn(dataset_name)

known_lineage = KnownQueryLineageInfo(
query_id=get_query_fingerprint(
query.query_text, self.identifiers.platform, fast=True
),
query_text=query.query_text,
downstream=downstream_table_urn,
upstreams=self.map_query_result_upstreams(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ class KnownQueryLineageInfo:
timestamp: Optional[datetime] = None
session_id: Optional[str] = None
query_type: QueryType = QueryType.UNKNOWN
query_id: Optional[str] = None


@dataclasses.dataclass
Expand Down Expand Up @@ -618,11 +619,13 @@ def add_known_query_lineage(
self.report.num_known_query_lineage += 1

# Generate a fingerprint for the query.
with self.report.sql_fingerprinting_timer:
query_fingerprint = get_query_fingerprint(
known_query_lineage.query_text,
platform=self.platform.platform_name,
)
query_fingerprint = known_query_lineage.query_id
if not query_fingerprint:
with self.report.sql_fingerprinting_timer:
query_fingerprint = get_query_fingerprint(
known_query_lineage.query_text,
platform=self.platform.platform_name,
)
formatted_query = self._maybe_format_query(known_query_lineage.query_text)

# Register the query.
Expand Down

0 comments on commit 91c1c6b

Please sign in to comment.