Commit 16a3f6c
[SPARK-54595][SQL] Keep existing behavior of MERGE INTO without SCHEMA EVOLUTION clause
### What changes were proposed in this pull request?
Keep existing behavior for MERGE INTO without SCHEMA EVOLUTION clause for UPDATE SET * and INSERT * as well as UPDATE struct or INSERT struct, to throw exception if the source and target schemas are not exactly the same.
### Why are the changes needed?
As aokolnychyi tested this feature, he mentioned that as of Spark 4.1 the behavior is changed for MERGE INTO but without SCHEMA EVOLUTION clause.
In particular:
- Source has less columns/nested fields than target => we fill with NULL or DEFAULT for inserts, and existing value for Update. (though we disabled for nested structs by default in [[SPARK-54525](https://issues.apache.org/jira/browse/SPARK-54525))](https://github.com/apache/spark/pull/53229)
- Source has more columns/fields than target => we drop the extra fields.
Initially, I thought its a good improvement of MERGE INTO and is not related to SCHEMA EVOLUTION exactly because the schema is not altered. But Anton has a good point that it may be a surprise to some user. So it may be better for now to be more conservative and keep the exact same behavior for without SCHEMA EVOLUTION clause.
Note: this behavior is still enabled if SCHEMA EVOLUTION is specified, as the user then is more explicit about the decision.
### Does this PR introduce _any_ user-facing change?
No, this keeps behavior exactly the same as 4.0 without SCHEMA EVOLUTION clause.
### How was this patch tested?
Added a test and changed existing test output to expect the exception if SCHEMA EVOLUTION is not specified.
### Was this patch authored or co-authored using generative AI tooling?
No
Closes #53326 from szehon-ho/merge_restriction.
Authored-by: Szehon Ho <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
(cherry picked from commit 74b6a93)
Signed-off-by: Dongjoon Hyun <[email protected]>1 parent edb2ac7 commit 16a3f6c
File tree
4 files changed
+711
-786
lines changed- sql
- catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis
- core/src/test/scala/org/apache/spark/sql
- connector
- execution/command
4 files changed
+711
-786
lines changedLines changed: 4 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1736 | 1736 | | |
1737 | 1737 | | |
1738 | 1738 | | |
1739 | | - | |
1740 | | - | |
1741 | | - | |
| 1739 | + | |
| 1740 | + | |
1742 | 1741 | | |
1743 | 1742 | | |
1744 | 1743 | | |
| |||
1775 | 1774 | | |
1776 | 1775 | | |
1777 | 1776 | | |
1778 | | - | |
1779 | | - | |
1780 | | - | |
| 1777 | + | |
| 1778 | + | |
1781 | 1779 | | |
1782 | 1780 | | |
1783 | 1781 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
0 commit comments