Fix get_table_types for bigquery and databricks materialized view and streaming table#1071
Conversation
|
Thanks for the PR! The fix for Databricks looks correct — However, I think the new So the suggestion would be:
For context: |
|
@b-per Thank you for the review and suggestions. I agree your suggestions are better! I have pushed those changes so would appreciate the re-review. I did start to change the default dispatch but I wasn't sure about the impact of modifying that would have on a bunch of other targets so I went with the more cautious BigQuery-only approach. I also wasn't sure about Postgres but have made that change too as you suggested. |
resolves #
#881
#861
Includes (corrected) fix from #862
Problem
I reproduce this bug using the dbt-codegen package, which in turn calls this dbt-utils package. Specifically I was trying to run
dbt run-operation generate_source --args '{"table_pattern": "%_raw"}'This ends up calling
dbt_utils.get_relations_by_patternwhich callsdbt_utils.get_tables_by_pattern_sqlto fetch metadata from information_schema and then passes it toapi.Relation.create()which then throws the errorSolution
The dbt-databricks adapter uses
DatabricksRelationType, see: https://github.com/databricks/dbt-databricks/blob/25caa2a14ed0535f08f6fd92e29b39df1f453e4d/dbt/adapters/databricks/relation.py#L40The dbt-bigquery adapter uses the base
RelationType, see: https://github.com/dbt-labs/dbt-adapters/blob/e966f0ddea91ae531d92e703696bb80144e5b28e/dbt-bigquery/src/dbt/adapters/bigquery/relation.py#L13and where it is used: https://github.com/dbt-labs/dbt-adapters/blob/e966f0ddea91ae531d92e703696bb80144e5b28e/dbt-adapters/src/dbt/adapters/contracts/relation.py#L20
Also see the databricks table_types documented here https://docs.databricks.com/aws/en/sql/language-manual/information-schema/tables#table-types
This PR is a very small fix, and I have verified it works on my own dbt projects by monkey-patching it with a file
./macros/get_table_types_sql.sqlwith the contents as per this PRChecklist
There are pre-existing tests for this macro, this PR is for a bug, not new functionality.
Not applicable, because functionality doesn't vary from the documented intention