mirror of
https://github.com/datahub-project/datahub.git
synced 2025-07-24 18:10:11 +00:00
fix(ingestion): Make AVRO schema parsing robust to exceptions. (#3541)
This commit is contained in:
parent
4bcc1f04f6
commit
c3f1bf0534
@ -440,8 +440,14 @@ def avro_schema_to_mce_fields(
|
||||
:param is_key_schema: True if it is a key-schema. Default is False (value-schema).
|
||||
:return: The list of MCE compatible SchemaFields.
|
||||
"""
|
||||
return list(
|
||||
AvroToMceSchemaConverter.to_mce_fields(
|
||||
avro_schema_string, is_key_schema, default_nullable
|
||||
schema_fields: List[SchemaField] = []
|
||||
try:
|
||||
schema_fields = list(
|
||||
AvroToMceSchemaConverter.to_mce_fields(
|
||||
avro_schema_string, is_key_schema, default_nullable
|
||||
)
|
||||
)
|
||||
)
|
||||
except Exception:
|
||||
logger.exception(f"Failed to parse {avro_schema_string} to mce_fields.")
|
||||
|
||||
return schema_fields
|
||||
|
@ -642,3 +642,19 @@ def test_key_schema_handling():
|
||||
assret_field_paths_match(fields, expected_field_paths)
|
||||
for f in fields:
|
||||
assert f.isPartOfKey
|
||||
|
||||
|
||||
def test_ignore_exceptions():
|
||||
schema: str = """
|
||||
["string",
|
||||
{
|
||||
"name": "event_ts",
|
||||
"type": "long",
|
||||
"logicalType": "timestamp-millis",
|
||||
"tags": [
|
||||
"business-timestamp"
|
||||
]
|
||||
}]
|
||||
"""
|
||||
fields: List[SchemaField] = avro_schema_to_mce_fields(schema, is_key_schema=False)
|
||||
assert not fields
|
||||
|
Loading…
x
Reference in New Issue
Block a user