Skip to content

Commit 59b0298

Browse files
Update core/dbt/include/global_project/macros/materializations/models/table/columns_spec_ddl.sql
For whitespace control in the dbt.log file! Co-authored-by: dave-connors-3 <[email protected]>
1 parent a501c29 commit 59b0298

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

core/dbt/include/global_project/macros/materializations/models/table/columns_spec_ddl.sql

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@
2828
{%- endmacro %}
2929

3030
{% macro assert_columns_equivalent(sql) %}
31+
{# loop through user_provided_columns to get column names #}
32+
{%- set user_provided_columns = model['columns'] -%}
33+
{%- set column_names_config_only = [] -%}
34+
{%- for i in user_provided_columns -%}
35+
{%- set col = user_provided_columns[i] -%}
36+
{%- set col_name = col['name'] -%}
37+
{%- set column_names_config_only = column_names_config_only.append(col_name) -%}
38+
{%- endfor -%}
39+
{%- set sql_file_provided_columns = get_columns_in_query(sql) -%}
40+
41+
{%- if column_names_config_only != sql_file_provided_columns -%}
42+
{%- do exceptions.raise_compiler_error('Please ensure the name and order of columns in your `yml` file match the columns in your SQL file.\nSchema File Columns: ' ~ column_names_config_only ~ '\nSQL File Columns: ' ~ sql_file_provided_columns ~ ' ' ) %}
43+
{%- endif -%}
44+
{% endmacro %}
3145
{# loop through user_provided_columns to get column names #}
3246
{%- set user_provided_columns = model['columns'] -%}
3347
{% set column_names_config_only = [] %}

0 commit comments

Comments
 (0)