Closed drewblinn closed 7 months ago
Hey @drewblinn ! thanks so much for the issue -- did a little digging, and I think this may indeed be an issue with dbt-postgres
. In our macro, we call adapter.get_columns_in_relation
here to populate the columns using the query you noted above. This actually calls the macro as defined within whichever dbt adapter you're using, and in your case, that postgres macro is defined here. Indeed, no checks to pg_catalog
!
I opened an issue on dbt-core over here -- hopefully we can get that fixed soon!
Thanks for taking a look @dave-connors-3! Let me know if I can help in any way
Thanks @drewblinn and @dave-connors-3 🏆
Just wrote up an explanation here.
TLDR: the definition of the information_schema.columns
view in postgres is just missing 'm'::"char"
which is causing [m]aterialized views to not show up.
@drewblinn that write-up contains a workaround you can try in the meantime. Could you give it a shot and see if it works for you?
@dbeatty10 the workaround works great! thanks for your work on this
Awesome to hear @drewblinn 🎉
I've opened a draft PR that contains this solution: https://github.com/dbt-labs/dbt-core/pull/9433
Since we're going to address the underlying issue in dbt-postgres, I'm closing this issue in favor of https://github.com/dbt-labs/dbt-core/issues/9419.
Describe the bug
The
generate_model_yaml
macro does not return any information about materialized views.The macro queries
information_schema.columns
which does not store data about materialized views.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']) }}
ordbt run-operation codegen.generate_model_yaml --args '{"model_names": ["mv_gene_yaml_test"]}'
Expected results
The macro should return columns
Actual results
The macro only returns the model name and description, no columns
Screenshots and log output
System information
The contents of your
packages.yml
file:Which database are you using dbt with?
The output of
dbt --version
: Command failed in dbt cloud, but I am using 1.7.4 as seen in the log aboveThe operating system you're using: Windows (dbt cloud)
The output of
python --version
: N/AAdditional context
The macro queries
information_schema.columns
which does not store data about materialized views. Column information for MVs can be found inpg_catalog.pg_attribute
Are you interested in contributing the fix?
More than happy to help!