-
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
[Bug] postgres get_columns_in_relation
does not include MVs
#9419
Comments
Thanks for opening this @dave-connors-3 🦞 TLDRAfter doing a little bit of digging, I think this is actually a bug (or short-sighted implementation) within the
|
Reprex
{{ config(materialized="materialized_view") }}
select
1 as int_col,
'one' as string_col,
FALSE as bool_col
{%- set relation = ref("my_mv") -%}
{%- set columns = adapter.get_columns_in_relation(relation) -%}
{% if columns | length == 0 -%}
{{ "No columns found in " ~ relation }}
{% endif %}
{% for column in columns -%}
{{ "Column: " ~ column }}
{% endfor %} Then run this command: dbt compile --select analyses/get_columns_in_relation.sql The output _should be:
But without the workaround above, you'll get this instead:
|
Is this a new bug in dbt-core?
Current Behavior
calling
adapter.get_columns_in_relation
on a materialized view returns 0 columns.Expected Behavior
calling
adapter.get_columns_in_relation
on a materialized view returns all the columns in the materialized view.Steps To Reproduce
Create a Materialized view
Build the Model
dbt build -s mv_gene_yaml_test
Run the macro
{{ codegen.generate_model_yaml(model_names=['mv_gene_yaml_test']) }}
or
dbt run-operation codegen.generate_model_yaml --args '{"model_names": ["mv_gene_yaml_test"]}'
(this is copied from a
dbt-codegen
issue. This macro usesadapter.get_columns_in_relation
under the hood. You could update the last step to call the macro directly.per @drewblinn in that issue:
Relevant log output
No response
Environment
Which database adapter are you using with dbt?
postgres
Additional Context
No response
The text was updated successfully, but these errors were encountered: