Closed RobertasPetrauskas1 closed 5 days ago
@RobertasPetrauskas1 can you email me a dbt.log: ben.cassell@databricks.com
I suspect that somewhere in migrating to using the system catalog for metadata that we're missing a catalog name.
Done. Let me know if you need anything else
Got it, will release a fix shortly.
Describe the bug
After databricks workflows bumped the adapter version to 1.8.2 our gold layer dimensional models started failing in both prod and in staging environments. Some context for clarity:
When running
dbt build --target staging
we expect the output in the gold layer to be a view, but dbt issuesdrop table if exists ...
commands resulting inRuntime Error [WRONG_COMMAND_FOR_OBJECT_TYPE] The operation DROP TABLE requires a EXTERNAL or MANAGED. But ... is a VIEW. Use DROP VIEW instead. SQLSTATE: 42809
When running
dbt build --target prod
we expect the output in the gold layer to be a table, but dbt issuesdrop view if exists ...
commands resulting inRuntime Error Error running query: org.apache.spark.sql.AnalysisException: Cannot drop a table with DROP VIEW. Please use DROP TABLE instead
Using databricks query history, I don't seem to find prior queries like
drop view if exists
ordrop table if exists
when running these models, so this change must have happened in 1.8.2. Not really sure why this is happening only on some gold models (3 out of 5 dimension tables fail, as well as downstream fact tables that are skipped). One thing I noticed is that if I delete all of the gold tables in the gold schema in UC, the firstdbt build
run is successful, but consecutive runs fail with the same errors.Steps To Reproduce
Currently I tried to reproduce this problem only on our own code locally by installing dbt-databricks 1.8.2 and running
dbt build
and got the same errors, but after downgrading to 1.8.1 the models run successfully. Don't really have time to create a test environment to reproduce this myself, but maybe will have time later if no obvious fix is found immediately.Expected behavior
dbt build
to work as it did before.Screenshots and log output
Not sure if I just dump the whole file here but might just add this later as a separate comment if needed.
System information
The output of
dbt --version
:The operating system you're using: macOS Sonoma 14.4.1
The output of
python --version
: Python 3.10.12Additional context
Macros for UC structure based on env:
get_custom_alias.sql:
get_custom_schema.sql:
dbt_project.yml: