Skip to content

Commit eb17f80

Browse files
feat(ingest/hive): identify partition columns in hive tables (#12833)
1 parent 0e62e8c commit eb17f80

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

metadata-ingestion/src/datahub/ingestion/source/sql/hive.py

+13
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,7 @@ def get_schema_fields_for_column(
777777
column,
778778
inspector,
779779
pk_constraints,
780+
partition_keys=partition_keys,
780781
)
781782

782783
if self._COMPLEX_TYPE.match(fields[0].nativeDataType) and isinstance(
@@ -849,3 +850,15 @@ def _process_view(
849850
default_db=default_db,
850851
default_schema=default_schema,
851852
)
853+
854+
def get_partitions(
855+
self, inspector: Inspector, schema: str, table: str
856+
) -> Optional[List[str]]:
857+
partition_columns: List[dict] = inspector.get_indexes(
858+
table_name=table, schema=schema
859+
)
860+
for partition_column in partition_columns:
861+
if partition_column.get("column_names"):
862+
return partition_column.get("column_names")
863+
864+
return []

metadata-ingestion/tests/integration/hive/hive_mces_all_db_golden.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1255,7 +1255,8 @@
12551255
},
12561256
"nativeDataType": "string",
12571257
"recursive": false,
1258-
"isPartOfKey": false
1258+
"isPartOfKey": false,
1259+
"isPartitioningKey": true
12591260
}
12601261
]
12611262
}

metadata-ingestion/tests/integration/hive/hive_mces_golden.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1255,7 +1255,8 @@
12551255
},
12561256
"nativeDataType": "string",
12571257
"recursive": false,
1258-
"isPartOfKey": false
1258+
"isPartOfKey": false,
1259+
"isPartitioningKey": true
12591260
}
12601261
]
12611262
}

0 commit comments

Comments
 (0)