From b6bd8fbec07a0531698e6cf061a19c3c72bbe041 Mon Sep 17 00:00:00 2001 From: Simon Harrer Date: Sat, 18 May 2024 12:26:08 +0200 Subject: [PATCH] Support config type --- datacontract/export/bigquery_converter.py | 2 +- datacontract/export/sql_type_converter.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/datacontract/export/bigquery_converter.py b/datacontract/export/bigquery_converter.py index 9094a88b..a8e210aa 100644 --- a/datacontract/export/bigquery_converter.py +++ b/datacontract/export/bigquery_converter.py @@ -20,7 +20,7 @@ def to_bigquery_schema(model_name: str, model_value: Model, server: Server) -> d "description": model_value.description, "schema": { "fields": to_fields_array(model_value.fields) - } + } } def to_fields_array(fields: Dict[str, Field]) -> List[Dict[str, Field]]: diff --git a/datacontract/export/sql_type_converter.py b/datacontract/export/sql_type_converter.py index 161f2b56..af1a347d 100644 --- a/datacontract/export/sql_type_converter.py +++ b/datacontract/export/sql_type_converter.py @@ -59,6 +59,9 @@ def convert_to_snowflake(field: Field) -> None | str: # https://www.postgresql.org/docs/current/datatype.html # Using the name whenever possible def convert_type_to_postgres(field: Field) -> None | str: + if field.config and field.config["postgresType"] is not None: + return field.config["postgresType"] + type = field.type if type is None: return None @@ -101,6 +104,9 @@ def convert_type_to_postgres(field: Field) -> None | str: # databricks data types: # https://docs.databricks.com/en/sql/language-manual/sql-ref-datatypes.html def convert_to_databricks(field) -> None | str: + if field.config and field.config["databricksType"] is not None: + return field.config["databricksType"] + type = field.type if type is None: return None