diff --git a/macros/edr/data_monitoring/schema_changes/get_columns_snapshot_query.sql b/macros/edr/data_monitoring/schema_changes/get_columns_snapshot_query.sql index 89a0bff49..6d21b02dc 100644 --- a/macros/edr/data_monitoring/schema_changes/get_columns_snapshot_query.sql +++ b/macros/edr/data_monitoring/schema_changes/get_columns_snapshot_query.sql @@ -14,6 +14,13 @@ {% set columns = adapter.get_columns_in_relation(model_relation) %} + {% if not columns %} + {% set no_columns_error -%} + Failed to detect columns for {{ model_relation }}. Ensure it exists and authorized. + {%- endset %} + exceptions.raise_compiler_error(no_columns_error) + {% endif %} + with table_info as ( select {{ elementary.edr_cast_as_string(elementary.edr_quote(full_table_name)) }} as full_table_name, @@ -91,4 +98,4 @@ {{ elementary.edr_cast_as_timestamp('detected_at') }} as detected_at from columns_snapshot_with_id -{%- endmacro %} \ No newline at end of file +{%- endmacro %}