Skip to content

Commit

Permalink
push logic back into base_node_columns, via get_column_values
Browse files Browse the repository at this point in the history
  • Loading branch information
katieclaiborne7 committed Jun 10, 2024
1 parent aea85e1 commit ac8f208
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions macros/unpack/get_column_values.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
wrap_string_with_quotes(dbt.escape_single_quotes(column.description)),
wrap_string_with_quotes(dbt.escape_single_quotes(column.data_type)),
wrap_string_with_quotes(dbt.escape_single_quotes(tojson(column.constraints))),
column.constraints | selectattr('type', 'equalto', 'not_null') | list | length > 0,
column.constraints | length,
wrap_string_with_quotes(dbt.escape_single_quotes(column.quote))
]
%}
Expand Down
4 changes: 2 additions & 2 deletions models/marts/tests/intermediate/int_model_test_summary.sql
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ count_column_constraints as (
node_unique_id as direct_parent_id,
name as column_name,
case
when replace(constraints, '"not_null"', '') != constraints
when has_not_null_constraint
then 1
else 0
end as constraint_not_null_count,
cast((length(constraints) - length(replace(constraints, 'type', ''))) / 4 as int) as constraints_count
constraints_count
from {{ ref('base_node_columns') }}

),
Expand Down
2 changes: 2 additions & 0 deletions models/staging/graph/base/base_node_columns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ select
cast(null as {{ dbt_project_evaluator.type_large_string()}}) as description,
cast(null as {{ dbt.type_string()}}) as data_type,
cast(null as {{ dbt.type_string()}}) as constraints,
cast(True as boolean) as has_not_null_constraint,
cast(0 as {{ dbt.type_int() }}) as constraints_count,
cast(null as {{ dbt.type_string()}}) as quote

from dummy_cte
Expand Down

0 comments on commit ac8f208

Please sign in to comment.