Skip to content

Commit 1a8635c

Browse files
fix: dispatch GROUP BY in get_columns_changes_query_generic for T-SQL compatibility
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
1 parent f3e8a33 commit 1a8635c

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

macros/edr/data_monitoring/schema_changes/get_columns_changes_query.sql

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@
200200
)
201201
else null
202202
end as test_results_description
203-
from all_column_changes {{ dbt_utils.group_by(9) }}
203+
from all_column_changes {{ elementary.schema_changes_query_group_by() }}
204204

205205
)
206206

@@ -242,6 +242,22 @@
242242
where lower(columns_snapshot.full_table_name) = lower('{{ full_table_name }}')
243243
{% endmacro %}
244244

245+
{% macro schema_changes_query_group_by() %}
246+
{{ return(adapter.dispatch("schema_changes_query_group_by", "elementary")()) }}
247+
{% endmacro %}
248+
249+
{% macro default__schema_changes_query_group_by() %}
250+
{{ dbt_utils.group_by(9) }}
251+
{% endmacro %}
252+
253+
{% macro fabric__schema_changes_query_group_by() %}
254+
{#- T-SQL does not support positional GROUP BY references and rejects
255+
GROUP BY on constant expressions (e.g. 'schema_change').
256+
Group by the 6 source columns from all_column_changes instead;
257+
all 9 output columns are deterministic functions of these. -#}
258+
group by full_table_name, change, column_name, data_type, pre_data_type, detected_at
259+
{% endmacro %}
260+
245261
{% macro fabric__get_column_changes_from_baseline_cur(
246262
model_relation, full_table_name, model_baseline_relation
247263
) %}

0 commit comments

Comments
 (0)