From 4774638f334908815ec685bb21877ac10ce200df Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Wed, 17 Apr 2024 16:41:18 -0400 Subject: [PATCH] [fix] use cast macro in default__get_empty_schema_sql (#165) --- .changes/unreleased/Fixes-20240411-185203.yaml | 6 ++++++ dbt/include/global_project/macros/adapters/columns.sql | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changes/unreleased/Fixes-20240411-185203.yaml diff --git a/.changes/unreleased/Fixes-20240411-185203.yaml b/.changes/unreleased/Fixes-20240411-185203.yaml new file mode 100644 index 00000000..5df91f93 --- /dev/null +++ b/.changes/unreleased/Fixes-20240411-185203.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: Fix adapter-specific cast handling for constraint enforcement +time: 2024-04-11T18:52:03.960202-07:00 +custom: + Author: michelleark + Issue: "166" diff --git a/dbt/include/global_project/macros/adapters/columns.sql b/dbt/include/global_project/macros/adapters/columns.sql index e1099649..663a827b 100644 --- a/dbt/include/global_project/macros/adapters/columns.sql +++ b/dbt/include/global_project/macros/adapters/columns.sql @@ -53,7 +53,7 @@ {%- do col_naked_numeric.append(col['name']) -%} {%- endif -%} {% set col_name = adapter.quote(col['name']) if col.get('quote') else col['name'] %} - cast(null as {{ col['data_type'] }}) as {{ col_name }}{{ ", " if not loop.last }} + {{ cast('null', col['data_type']) }} as {{ col_name }}{{ ", " if not loop.last }} {%- endfor -%} {%- if (col_err | length) > 0 -%} {{ exceptions.column_type_missing(column_names=col_err) }}