Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ingest): presto-on-hive - not failing on Hive type parsing error (#…
…6118) Co-authored-by: Shirshanka Das <shirshanka@apache.org>
- Loading branch information
1 parent
95afc1d
commit 2f79b50
Showing
4 changed files
with
79 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
37 changes: 37 additions & 0 deletions
37
metadata-ingestion/tests/unit/utilities/test_hive_schema_to_avro.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from datahub.metadata.schema_classes import ( | ||
NullTypeClass, | ||
NumberTypeClass, | ||
RecordTypeClass, | ||
) | ||
from datahub.utilities.hive_schema_to_avro import get_schema_fields_for_hive_column | ||
|
||
|
||
def test_get_avro_schema_for_hive_column(): | ||
schema_fields = get_schema_fields_for_hive_column("test", "int") | ||
assert schema_fields[0].type.type == NumberTypeClass() | ||
# Len will be the struct + 2 key there which should remain after the deduplication | ||
assert len(schema_fields) == 1 | ||
|
||
|
||
def test_get_avro_schema_for_struct_hive_column(): | ||
schema_fields = get_schema_fields_for_hive_column("test", "struct<test:int>") | ||
assert schema_fields[0].type.type == RecordTypeClass() | ||
assert len(schema_fields) == 2 | ||
|
||
|
||
def test_get_avro_schema_for_struct_hive_with_duplicate_column(): | ||
schema_fields = get_schema_fields_for_hive_column( | ||
"test", "struct<test:int, test2:int, test:int>" | ||
) | ||
assert schema_fields[0].type.type == RecordTypeClass() | ||
# Len will be the struct + 2 key there which should remain after the deduplication | ||
assert len(schema_fields) == 3 | ||
|
||
|
||
def test_get_avro_schema_for_struct_hive_with_duplicate_column2(): | ||
invalid_schema: str = "struct!test:intdsfs, test2:int, test:int>" | ||
schema_fields = get_schema_fields_for_hive_column("test", invalid_schema) | ||
assert len(schema_fields) == 1 | ||
assert schema_fields[0].type.type == NullTypeClass() | ||
assert schema_fields[0].fieldPath == "test" | ||
assert schema_fields[0].nativeDataType == invalid_schema |