cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

BUG: Merge with schema evolution doesn't work in update clause

Dhruv-22
Contributor II

I am referring to this link of databricks documentation. Here is a screenshot of the same Screenshot 2026-01-09 at 16.33.15.png

 

According to the documentation the UPDATE command should work when the target table doesn't have the column but it is present in source. I tried the same with the following code and it failed.

%sql
CREATE OR REPLACE TABLE edw_nprd_aen.bronze.test_table (
  a INT
  , b STRING
);

INSERT INTO edw_nprd_aen.bronze.test_table
VALUES (1, 'a'), (2, 'b'), (3, 'c');

SELECT *
FROM edw_nprd_aen.bronze.test_table

Dhruv22_0-1767956896097.png

%sql
CREATE OR REPLACE TEMPORARY VIEW test_view (
  a
  , c
)
AS VALUES (1, 'e'), (2, NULL), (3, 'd');
%sql
MERGE WITH SCHEMA EVOLUTION INTO edw_nprd_aen.bronze.test_table
USING test_view
ON test_table.a = test_view.a
WHEN MATCHED THEN UPDATE SET
  test_table.c = test_view.c

#Output
[DELTA_MERGE_UNRESOLVED_EXPRESSION] Cannot resolve test_table.c in UPDATE clause given columns test_view.a, test_view.c. SQLSTATE: 42601
== SQL (line 1, position 1) ==
MERGE WITH SCHEMA EVOLUTION INTO edw_nprd_aen.bronze.test_table
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
USING test_view
^^^^^^^^^^^^^^^
ON test_table.a = test_view.a
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
WHEN MATCHED THEN UPDATE SET
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  test_table.c = test_view.c
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I have run this on both serverless and all-purpose cluster.

2 REPLIES 2

iyashk-DB
Databricks Employee
Databricks Employee

@Dhruv-22 I tested this and when I do something like follows, it works:

%sql
MERGE WITH SCHEMA EVOLUTION INTO main.yash.test_table
USING test_view
ON test_table.a = test_view.a
WHEN MATCHED THEN
  UPDATE SET c = test_view.c

 Instead of mentioning it as test_table.c, I just did c, and it worked. Screenshot 2026-01-09 at 5.41.35 PM.png

Dhruv-22
Contributor II

Hi @iyashk-DB

Thanks for the response, it will help in resolving the issue.

But, can you mark it as a bug and report it? Because specifying just the column without the table name is a little risky.