Skip to content

Commit a1f53bd

Browse files
committed
Also validate schemas if node.columns is not defined.
1 parent a02f1a1 commit a1f53bd

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

transform/macros/validate_all_schemas.sql

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
-- Add models to the list
1414
{%- for node_id, node in graph.nodes.items() -%}
15-
{%- if node.resource_type == 'model' and node.columns -%}
15+
{%- if node.resource_type == 'model' -%}
1616
{%- do table_info.append({
1717
'name': node.name,
1818
'schema': node.schema,
@@ -24,14 +24,12 @@
2424

2525
-- Add sources to the list
2626
{%- for source_id, source in graph.sources.items() -%}
27-
{%- if source.columns -%}
28-
{%- do table_info.append({
29-
'name': source.name,
30-
'schema': source.schema,
31-
'database': source.database,
32-
'type': 'source'
33-
}) -%}
34-
{%- endif -%}
27+
{%- do table_info.append({
28+
'name': source.name,
29+
'schema': source.schema,
30+
'database': source.database,
31+
'type': 'source'
32+
}) -%}
3533
{%- endfor -%}
3634

3735
{%- if table_info | length == 0 -%}
@@ -138,9 +136,11 @@
138136

139137
-- Get documented columns
140138
{%- set documented_columns = [] -%}
141-
{%- for column_name, column_info in node.columns.items() -%}
142-
{%- do documented_columns.append(column_name.upper()) -%}
143-
{%- endfor -%}
139+
{%- if node.columns -%}
140+
{%- for column_name, column_info in node.columns.items() -%}
141+
{%- do documented_columns.append(column_name.upper()) -%}
142+
{%- endfor -%}
143+
{%- endif -%}
144144

145145
-- Find missing and undocumented columns
146146
{%- set documented_but_missing_columns = [] -%}
@@ -221,18 +221,16 @@
221221

222222
-- Validate models
223223
{%- for node_id, node in graph.nodes.items() -%}
224-
{%- if node.resource_type == 'model' and node.columns -%}
224+
{%- if node.resource_type == 'model' -%}
225225
{%- set result = _validate_single_table_schema(node, table_columns_info, 'model') -%}
226226
{%- do validation_results.append(result) -%}
227227
{%- endif -%}
228228
{%- endfor -%}
229229

230230
-- Validate sources
231231
{%- for source_id, source in graph.sources.items() -%}
232-
{%- if source.columns -%}
233-
{%- set result = _validate_single_table_schema(source, table_columns_info, 'source') -%}
234-
{%- do validation_results.append(result) -%}
235-
{%- endif -%}
232+
{%- set result = _validate_single_table_schema(source, table_columns_info, 'source') -%}
233+
{%- do validation_results.append(result) -%}
236234
{%- endfor -%}
237235

238236
-- Process all validation results

0 commit comments

Comments
 (0)