-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Contracts: Handle struct column specified both at root and nested levels + arrays of structs #806
Changes from 8 commits
bac87f5
41725f6
51654f4
53b291d
b761089
d45b973
fb9210d
2ab4fef
6f1595b
f05c784
8544f4c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
kind: Fixes | ||
body: 'Contracts: Handle struct column specified both at root and nested levels + | ||
arrays of structs' | ||
time: 2023-06-30T21:31:12.63257-04:00 | ||
custom: | ||
Author: michelleark | ||
Issue: 781 782 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,16 @@ | |
{%- endmacro -%} | ||
|
||
{% macro bigquery__get_empty_schema_sql(columns) %} | ||
{%- set col_err = [] -%} | ||
{% for col in columns.values() %} | ||
{%- if col['data_type'] is not defined -%} | ||
{{ col_err.append(col['name']) }} | ||
{%- endif -%} | ||
{%- endfor -%} | ||
{%- if (col_err | length) > 0 -%} | ||
{{ exceptions.column_type_missing(column_names=col_err) }} | ||
{%- endif -%} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR introduces some unsatisfying duplication in the bigquery version of the However, it's necessary to do this before the columns get nested to provide granular error messages as opposed to deferring it to the handling in Once the nested handling of model contracts moves into core, this duplication should be resolved and only present in the |
||
|
||
{%- set columns = adapter.nest_column_data_types(columns) -%} | ||
{{ return(dbt.default__get_empty_schema_sql(columns)) }} | ||
{% endmacro %} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need the
or [None]
here? I thought I tried this in a toy example where.pop()
returned""
and it still worked as anticipated. But I might have missed some edge case.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately not :( it broke a couple unit tests with the following error: