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

fix(metadata-ingestion)glue connector failure when Optional field Type of PartitionKey is absent for a Table #10052

Merged
Show file tree
Hide file tree
Changes from 8 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
6 changes: 5 additions & 1 deletion metadata-ingestion/src/datahub/ingestion/source/aws/glue.py
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,10 @@ def _transform_extraction(self) -> Iterable[MetadataWorkUnit]:
def _extract_record(
self, dataset_urn: str, table: Dict, table_name: str
) -> MetadataChangeEvent:
logger.debug(
f"extract record from table={table_name} for dataset={dataset_urn}"
)

def get_owner() -> Optional[OwnershipClass]:
owner = table.get("Owner")
if owner:
Expand Down Expand Up @@ -1163,7 +1167,7 @@ def get_schema_metadata() -> Optional[SchemaMetadata]:
for partition_key in partition_keys:
schema_fields = get_schema_fields_for_hive_column(
hive_column_name=partition_key["Name"],
hive_column_type=partition_key["Type"],
hive_column_type=partition_key.get("Type", "unknown"),
default_nullable=False,
)
assert schema_fields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class HiveColumnToAvroConverter:
"bigint": "long",
"varchar": "string",
"char": "string",
"unknown": "null",
hsheth2 marked this conversation as resolved.
Show resolved Hide resolved
}

_COMPLEX_TYPE = re.compile("^(struct|map|array|uniontype)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,11 @@ def test_get_avro_schema_for_struct_hive_with_duplicate_column2():
assert schema_fields[0].type.type == NullTypeClass()
assert schema_fields[0].fieldPath == "test"
assert schema_fields[0].nativeDataType == invalid_schema


def test_get_avro_schema_for_null_type_hive_column():
schema_fields = get_schema_fields_for_hive_column(
hive_column_name="test", hive_column_type="unknown"
)
assert schema_fields[0].type.type == NullTypeClass()
assert len(schema_fields) == 1
Loading