mirror of
https://github.com/datahub-project/datahub.git
synced 2025-12-16 20:48:35 +00:00
fix(ingestion): correct trino datatype handling (#5541)
Co-authored-by: Ravindra Lanka <rlanka@acryl.io>
This commit is contained in:
parent
9a3ee1cb6b
commit
fa42b59d9f
@ -228,9 +228,10 @@ def resolve_postgres_modified_type(type_string: str) -> Any:
|
|||||||
|
|
||||||
|
|
||||||
def resolve_trino_modified_type(type_string: str) -> Any:
|
def resolve_trino_modified_type(type_string: str) -> Any:
|
||||||
# for cases like timestamp(3)
|
# for cases like timestamp(3), decimal(10,0), row(...)
|
||||||
if re.match(r"[a-zA-Z]+\([0-9]+\)", type_string):
|
match = re.match(r"([a-zA-Z]+)\(.+\)", type_string)
|
||||||
modified_type_base = re.match(r"([a-zA-Z]+)\([0-9]+\)", type_string).group(1) # type: ignore
|
if match:
|
||||||
|
modified_type_base: str = match.group(1)
|
||||||
return TRINO_SQL_TYPES_MAP[modified_type_base]
|
return TRINO_SQL_TYPES_MAP[modified_type_base]
|
||||||
else:
|
else:
|
||||||
return TRINO_SQL_TYPES_MAP[type_string]
|
return TRINO_SQL_TYPES_MAP[type_string]
|
||||||
@ -337,4 +338,5 @@ TRINO_SQL_TYPES_MAP = {
|
|||||||
"date": DateType,
|
"date": DateType,
|
||||||
"time": TimeType,
|
"time": TimeType,
|
||||||
"timestamp": TimeType,
|
"timestamp": TimeType,
|
||||||
|
"row": RecordType,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -644,8 +644,25 @@ def test_dbt_stateful_tests(pytestconfig, tmp_path, mock_time, mock_datahub_grap
|
|||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"data_type, expected_data_type",
|
"data_type, expected_data_type",
|
||||||
[
|
[
|
||||||
("timestamp(3)", "timestamp"),
|
("boolean", "boolean"),
|
||||||
|
("tinyint", "tinyint"),
|
||||||
|
("smallint", "smallint"),
|
||||||
|
("int", "int"),
|
||||||
|
("integer", "integer"),
|
||||||
|
("bigint", "bigint"),
|
||||||
|
("real", "real"),
|
||||||
|
("double", "double"),
|
||||||
|
("decimal(10,0)", "decimal"),
|
||||||
("varchar(20)", "varchar"),
|
("varchar(20)", "varchar"),
|
||||||
|
("char", "char"),
|
||||||
|
("varbinary", "varbinary"),
|
||||||
|
("json", "json"),
|
||||||
|
("date", "date"),
|
||||||
|
("time", "time"),
|
||||||
|
("time(12)", "time"),
|
||||||
|
("timestamp", "timestamp"),
|
||||||
|
("timestamp(3)", "timestamp"),
|
||||||
|
("row(x bigint, y double)", "row"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_resolve_trino_modified_type(data_type, expected_data_type):
|
def test_resolve_trino_modified_type(data_type, expected_data_type):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user