diff --git a/dbtmetabase/metabase.py b/dbtmetabase/metabase.py index 515c6b9..a8f12d5 100644 --- a/dbtmetabase/metabase.py +++ b/dbtmetabase/metabase.py @@ -389,7 +389,10 @@ def export_column( if api_field["fk_target_field_id"] and not fk_target_field_id: fk_target_field_id = api_field["fk_target_field_id"] - body_field = {} + api_settings = api_field.get("settings") or {} + body_field = { + "settings": api_settings.copy(), + } if api_field.get("display_name") != column_display_name: body_field["display_name"] = column_display_name if api_field.get("description") != column_description: @@ -398,6 +401,21 @@ def export_column( body_field["visibility_type"] = column_visibility if api_field.get("fk_target_field_id") != fk_target_field_id: body_field["fk_target_field_id"] = fk_target_field_id + if ( + api_field.get("has_field_values") != column.has_field_values + and column.has_field_values + ): + body_field["has_field_values"] = column.has_field_values + if ( + api_field.get("coercion_strategy") != column.coercion_strategy + and column.coercion_strategy + ): + body_field["coercion_strategy"] = column.coercion_strategy + if ( + api_settings.get("number_style") != column.number_style + and column.number_style + ): + body_field["settings"]["number_style"] = column.number_style # Allow explicit null type to override detected one if api_field.get(semantic_type_key) != column.semantic_type and ( diff --git a/dbtmetabase/models/metabase.py b/dbtmetabase/models/metabase.py index 3ce2a41..10a4fac 100644 --- a/dbtmetabase/models/metabase.py +++ b/dbtmetabase/models/metabase.py @@ -13,6 +13,9 @@ # Must be covered by MetabaseColumn attributes METABASE_COLUMN_META_FIELDS = METABASE_MODEL_META_FIELDS + [ "semantic_type", + "has_field_values", + "coercion_strategy", + "number_style", ] # Default model schema (only schema in BigQuery) @@ -34,6 +37,9 @@ class MetabaseColumn: semantic_type: Optional[str] = None visibility_type: Optional[str] = None + has_field_values: Optional[str] = None + coercion_strategy: Optional[str] = None + number_style: Optional[str] = None fk_target_table: Optional[str] = None fk_target_field: Optional[str] = None