-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[ADAP-974][CT-3230] [Bug] type
should not be set to null
for dynamic tables and materialized view
#8864
[ADAP-974][CT-3230] [Bug] type
should not be set to null
for dynamic tables and materialized view
#8864
Comments
type
should not be set to null
dynamic tables and materialized viewtype
should not be set to null
dynamic tables and materialized view
type
should not be set to null
dynamic tables and materialized viewtype
should not be set to null
for dynamic tables and materialized view
Question from refinement: |
If/when we have a fix for this @eddowh and @amychen1776 requested if this could be backported for >=1.6. |
This is most pressing on Snowflake, but we should review the catalog queries for all adapters:
So to summarize: This is (potentially) wrong on all adapters, but |
The only currently known adapter that triggers this issue is dbt-snowflake. But this being a required field in dbt-core could also be considered the root cause. Solution in dbt-coreTwo options in dbt-core:
Solution in dbt-snowflakeThe workaround provided by @jtcohen6 (which might also be the solution for dbt-snowflake): {% macro snowflake__get_catalog_tables_sql(information_schema) -%}
select
table_catalog as "table_database",
table_schema as "table_schema",
table_name as "table_name",
-- this is the line to change
coalesce(table_type, "DYNAMIC TABLE") as "table_type",
comment as "table_comment",
-- note: this is the _role_ that owns the table
table_owner as "table_owner",
'Clustering Key' as "stats:clustering_key:label",
clustering_key as "stats:clustering_key:value",
'The key used to cluster this table' as "stats:clustering_key:description",
(clustering_key is not null) as "stats:clustering_key:include",
'Row Count' as "stats:row_count:label",
row_count as "stats:row_count:value",
'An approximate count of rows in this table' as "stats:row_count:description",
(row_count is not null) as "stats:row_count:include",
'Approximate Size' as "stats:bytes:label",
bytes as "stats:bytes:value",
'Approximate size of the table as reported by Snowflake' as "stats:bytes:description",
(bytes is not null) as "stats:bytes:include",
'Last Modified' as "stats:last_modified:label",
to_varchar(convert_timezone('UTC', last_altered), 'yyyy-mm-dd HH24:MI'||'UTC') as "stats:last_modified:value",
'The timestamp for last update/change' as "stats:last_modified:description",
(last_altered is not null and table_type='BASE TABLE') as "stats:last_modified:include"
from {{ information_schema }}.tables
{%- endmacro %} |
@jtcohen6 beat me to the reply button! :sonic: Proposed acceptance criteriaBased off the comment in #8864 (comment), one option could be to add a functional test that confirms the i.e. a workflow like this:
|
Incorrectly closed due to automation. |
Incorrectly closed due to automation...again. |
type
should not be set to null
for dynamic tables and materialized viewtype
should not be set to null
for dynamic tables and materialized view
I did some things. Please take a look at the four PRs attached to this issue. It's worth noting that all four adapters which support materialized views ( I'd like to call out one thing in particular; it looks like we're not consistent across adapters with what |
Thanks for calling this out @mikealfare @mikealfare ! 🏆 Created a separate issue to follow-up on this piece that you called out. The issue description is just an initial stub right now, but we will flesh it out as-needed: |
Is this a new bug in dbt-core?
Summary
A succinct summary by @jtcohen6:
if table be static
type table - pragmatic
if table dynamic
null type - panic!
Current Behavior
This is showing up in
catalog.json
with materialized views / dynamic tables: there are model nodes that havemetadata.type
:null
.Expected Behavior
Table
type
should be a required field that is nevernull
.We should create some kind of integration test to validate that the value is not null.
Steps To Reproduce
Run
dbt docs generate
within a dbt project that contains a model materialized as a dynamic table (Snowflake) or materialized view (other adapters). Examinecatalog.json
and see that node > metadata > type isnull
.Relevant log output
catalog.json
versus the expected JSON schemacatalog.json
expected JSON schema
Environment
Which database adapter are you using with dbt?
dbt-snowflake is where this was noticed, but we expect this to affect other adapters as well.
Additional Context
Internal slack thread:
https://dbt-labs.slack.com/archives/C05FWBP9X1U/p1697228694650389
Related issues
type
should not be set tonull
for dynamic tables and materialized view #8864The text was updated successfully, but these errors were encountered: