Skip to content

Commit 6ece48b

Browse files
refactor(ingest/bigquery): partition discovery metadata layer (stack 5/9) (#19482)
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 5ea33bf commit 6ece48b

7 files changed

Lines changed: 1450 additions & 1 deletion

File tree

metadata-ingestion/src/datahub/ingestion/source/bigquery_v2/profiling/constants.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
import re
2-
from typing import Set, Tuple
2+
from typing import Dict, Set, Tuple
33

44
# BigQuery partition ID lengths for date/time formats: YYYYMMDD and YYYYMMDDHH.
55
PARTITION_ID_YYYYMMDD_LENGTH = 8
66
PARTITION_ID_YYYYMMDDHH_LENGTH = 10
77

8+
# How many most-recently-modified populated partitions to pull from
9+
# INFORMATION_SCHEMA.PARTITIONS when deriving a partition filter. Small: the first one
10+
# that verifies as having data wins, so this only bounds how many candidates we try.
11+
MAX_PARTITIONS_TO_FETCH = 10
12+
13+
# Ingestion-time partitioned tables are partitioned on BigQuery pseudo-columns that
14+
# never appear in INFORMATION_SCHEMA.COLUMNS, so their data types can't be looked up
15+
# there. Their types are fixed by BigQuery, so map them directly — otherwise the filter
16+
# builder falls back to string point-equality instead of a typed half-open range.
17+
PSEUDO_PARTITION_COLUMN_TYPES: Dict[str, str] = {
18+
"_PARTITIONTIME": "TIMESTAMP",
19+
"_PARTITIONDATE": "DATE",
20+
}
21+
822

923
# Column names that suggest date/time data, used as a fallback when type info is
1024
# unavailable. 'day' is excluded: in partition contexts it's usually a day number (1-31).

metadata-ingestion/src/datahub/ingestion/source/bigquery_v2/profiling/partition_discovery/discovery.py

Lines changed: 529 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)