Commit 09aadf7
[SPARK-54172][SQL] Merge Into Schema Evolution should only add referenced columns
### What changes were proposed in this pull request?
Change MERGE INTO schema evolution scope. Limit the scope of schema evolution to only add columns/nested fields that exist in source and which are directly assigned to the source column without transformation.
ie,
```
UPDATE SET new_col = source.new_col
UPDATE SET struct.new_field = source.struct.new_field
INSERT (old_col, new_col) VALUES (s.old_col, s.new_col)
```
### Why are the changes needed?
#51698 added schema evolution support for MERGE INTO statements. However, it is a bit too broad. In some instances, source table may have many more fields than target tables. But user may only need a few new ones to be added to the target for the MERGE INTO statement.
### Does this PR introduce _any_ user-facing change?
No, MERGE INTO schema evolution is not yet released in Spark 4.1.
### How was this patch tested?
Added many unit tests in MergeIntoTableSuiteBase
### Was this patch authored or co-authored using generative AI tooling?
No
Closes #52866 from szehon-ho/merge_schema_evolution_limit_cols.
Authored-by: Szehon Ho <szehon.apache@gmail.com>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
(cherry picked from commit 03eb023)
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>1 parent d5d9ab0 commit 09aadf7
File tree
6 files changed
+1197
-189
lines changed- sql
- catalyst/src/main/scala/org/apache/spark/sql/catalyst
- analysis
- plans/logical
- core/src/test/scala/org/apache/spark/sql
- connector
- execution/command
6 files changed
+1197
-189
lines changedLines changed: 62 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1670 | 1670 | | |
1671 | 1671 | | |
1672 | 1672 | | |
1673 | | - | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
| 1677 | + | |
| 1678 | + | |
1674 | 1679 | | |
1675 | 1680 | | |
1676 | 1681 | | |
| |||
1680 | 1685 | | |
1681 | 1686 | | |
1682 | 1687 | | |
| 1688 | + | |
| 1689 | + | |
| 1690 | + | |
1683 | 1691 | | |
1684 | 1692 | | |
1685 | 1693 | | |
| |||
1691 | 1699 | | |
1692 | 1700 | | |
1693 | 1701 | | |
1694 | | - | |
| 1702 | + | |
| 1703 | + | |
1695 | 1704 | | |
1696 | | - | |
1697 | | - | |
1698 | | - | |
1699 | | - | |
1700 | | - | |
1701 | | - | |
| 1705 | + | |
| 1706 | + | |
| 1707 | + | |
| 1708 | + | |
| 1709 | + | |
| 1710 | + | |
| 1711 | + | |
| 1712 | + | |
| 1713 | + | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
| 1717 | + | |
| 1718 | + | |
| 1719 | + | |
| 1720 | + | |
1702 | 1721 | | |
1703 | 1722 | | |
1704 | 1723 | | |
1705 | | - | |
| 1724 | + | |
| 1725 | + | |
1706 | 1726 | | |
1707 | 1727 | | |
1708 | 1728 | | |
| |||
1713 | 1733 | | |
1714 | 1734 | | |
1715 | 1735 | | |
1716 | | - | |
| 1736 | + | |
| 1737 | + | |
1717 | 1738 | | |
1718 | 1739 | | |
1719 | 1740 | | |
1720 | 1741 | | |
1721 | 1742 | | |
1722 | | - | |
1723 | | - | |
1724 | | - | |
1725 | | - | |
1726 | | - | |
1727 | | - | |
| 1743 | + | |
| 1744 | + | |
| 1745 | + | |
| 1746 | + | |
| 1747 | + | |
| 1748 | + | |
| 1749 | + | |
| 1750 | + | |
| 1751 | + | |
| 1752 | + | |
| 1753 | + | |
| 1754 | + | |
| 1755 | + | |
| 1756 | + | |
| 1757 | + | |
| 1758 | + | |
1728 | 1759 | | |
1729 | 1760 | | |
1730 | | - | |
| 1761 | + | |
| 1762 | + | |
1731 | 1763 | | |
1732 | 1764 | | |
1733 | 1765 | | |
| |||
1741 | 1773 | | |
1742 | 1774 | | |
1743 | 1775 | | |
1744 | | - | |
| 1776 | + | |
| 1777 | + | |
1745 | 1778 | | |
1746 | 1779 | | |
1747 | 1780 | | |
| |||
1818 | 1851 | | |
1819 | 1852 | | |
1820 | 1853 | | |
1821 | | - | |
| 1854 | + | |
| 1855 | + | |
1822 | 1856 | | |
1823 | 1857 | | |
1824 | 1858 | | |
1825 | | - | |
| 1859 | + | |
1826 | 1860 | | |
1827 | 1861 | | |
1828 | 1862 | | |
| |||
1842 | 1876 | | |
1843 | 1877 | | |
1844 | 1878 | | |
1845 | | - | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
1846 | 1882 | | |
1847 | 1883 | | |
1848 | 1884 | | |
1849 | 1885 | | |
1850 | 1886 | | |
1851 | 1887 | | |
1852 | 1888 | | |
1853 | | - | |
1854 | | - | |
1855 | | - | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
1856 | 1894 | | |
1857 | 1895 | | |
1858 | 1896 | | |
| |||
Lines changed: 11 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
425 | 425 | | |
426 | 426 | | |
427 | 427 | | |
428 | | - | |
| 428 | + | |
| 429 | + | |
429 | 430 | | |
430 | 431 | | |
431 | 432 | | |
| |||
435 | 436 | | |
436 | 437 | | |
437 | 438 | | |
438 | | - | |
| 439 | + | |
439 | 440 | | |
440 | 441 | | |
441 | 442 | | |
| |||
475 | 476 | | |
476 | 477 | | |
477 | 478 | | |
478 | | - | |
479 | | - | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
480 | 487 | | |
481 | 488 | | |
482 | 489 | | |
| |||
Lines changed: 25 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
41 | 55 | | |
42 | | - | |
| 56 | + | |
43 | 57 | | |
44 | 58 | | |
45 | | - | |
46 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
47 | 63 | | |
48 | 64 | | |
49 | | - | |
50 | 65 | | |
51 | 66 | | |
52 | 67 | | |
53 | 68 | | |
54 | | - | |
| 69 | + | |
55 | 70 | | |
56 | 71 | | |
57 | 72 | | |
| |||
0 commit comments