You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
use_safer_relation_operations: replacing a view fails with UNRESOLVED_COLUMN when its upstream columns changed in the same run #1714
With use_materialization_v2: true and use_safer_relation_operations: true, replacing an existing view goes through safely_replace. That calls create_backup, which issues ALTER VIEW <view> RENAME TO <view>__dbt_backup.
Databricks analyses the old view definition again when it renames a view. If an upstream relation in the same run dropped or renamed a column the old view uses, the rename fails and the build stops:
alter view `cat`.`sch`.`my_view` rename to `cat`.`sch`.`my_view__dbt_backup`
[UNRESOLVED_COLUMN.WITH_SUGGESTION] A column, variable, or function parameter with name `old_col` cannot be resolved. Did you mean one of the following? [...]. SQLSTATE: 42703
That situation is the normal reason a view gets rebuilt: its upstream changed. The failed run leaves the old, broken view in place, so every retry fails the same way until someone drops the view by hand.
{{ config(materialized='view') }}
select id, old_col from {{ ref('s') }}
Run dbt build.
Rename the seed column to new_col and update v.sql to select new_col.
Run dbt build --full-refresh -s s+.
The seed is recreated with the new column, then v fails on ALTER VIEW ... RENAME TO ...__dbt_backup with UNRESOLVED_COLUMN.
Without --full-refresh the same thing happens whenever view_update_via_alter is off or the change needs a full replace.
Expected behavior
The view is replaced. A view holds no data, so renaming it to a backup protects nothing, and CREATE OR REPLACE VIEW is already atomic.
Possible fixes in databricks__get_replace_sql (macros/relations/replace.sql):
Use get_replace_view_sql (CREATE OR REPLACE VIEW) for view-to-view replaces even when use_safer_relation_operations is on.
Or, in safely_replace, drop the existing view instead of renaming it to a backup.
Workaround
Override replace_with_view in the project so that view-to-view replaces call get_replace_view_sql directly. Tables and incrementals keep the safer path.
System information
dbt-core: 1.11.7
dbt-databricks: 1.12.4 (the code path is unchanged on main / 1.12.7)
Opened #1733 for this, going with the first option you suggested (view to view uses CREATE OR REPLACE VIEW even with safer relation operations on). I don't have a workspace to reproduce it, so it has unit tests plus a functional test that does the column rename from your steps.
Activity
fix: use CREATE OR REPLACE for view-to-view replaces in safer mode
shantanutheone commentedon Oct 17, 2026
Opened #1733 for this, going with the first option you suggested (view to view uses CREATE OR REPLACE VIEW even with safer relation operations on). I don't have a workspace to reproduce it, so it has unit tests plus a functional test that does the column rename from your steps.