After running a model materialized as a view, cannot run the same model with table materialization.
{{ config(materialized="view") }} --> {{ config(materialized="table") }}
I include example log below. It seems that dbt when rerunning the model incorrectly issues DROP TABLE command although it should DROP VIEW instead.
(venv) >dbt run
13:47:57 Running with dbt=1.7.17
13:47:58 Registered adapter: sqlserver=1.7.4
13:47:58 Found 2 models, 4 tests, 0 sources, 0 exposures, 0 metrics, 447 macros, 0 groups, 0 semantic models
13:47:58
13:47:59 Concurrency: 1 threads (target='dev')
13:47:59
13:47:59 1 of 2 START sql table model schema_dbt.my_first_dbt_model ..................... [RUN]
13:47:59 1 of 2 ERROR creating sql table model schema_dbt.my_first_dbt_model ............ [ERROR in 0.44s]
13:47:59 2 of 2 SKIP relation schema_dbt.my_second_dbt_model ............................ [SKIP]
13:47:59
13:47:59 Finished running 1 table model, 1 view model in 0 hours 0 minutes and 1.12 seconds (1.12s).
13:48:00
13:48:00 Completed with 1 error and 0 warnings:
13:48:00
13:48:00 Database Error in model my_first_dbt_model (models\example\my_first_dbt_model.sql)
('42000', "[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Cannot use DROP TABLE with 'schema_dbt.my_first_dbt_model__dbt_backup' because 'schema_dbt.my_first_dbt_model__dbt_backup' is a view. Use DROP VIEW. (3705) (SQLMoreResults)")
compiled Code at target\run\my_dbt_test_project\models\example\my_first_dbt_model.sql
13:48:00
13:48:00 Done. PASS=0 WARN=0 ERROR=1 SKIP=1 TOTAL=2
After running a model materialized as a
view
, cannot run the same model withtable
materialization.{{ config(materialized="view") }}
-->{{ config(materialized="table") }}
I include example log below. It seems that dbt when rerunning the model incorrectly issues
DROP TABLE
command although it shouldDROP VIEW
instead.