Commit efa725e
[SPARK-56343][SQL][TESTS] Add MERGE INTO test for type mismatch without schema evolution trigger condition
### What changes were proposed in this pull request?
Add two tests to `MergeIntoSchemaEvolutionTypeWideningAndExtraFieldTests` for MERGE INTO schema evolution with cross-column assignments (which does not trigger schema evolution), where the source has a type mismatch on a same-named column:
1. **No evolution for compatible cross-column assignment**: `UPDATE SET salary = s.bonus` where `source.salary` is LONG and `target.salary` is INT. Since the assignment uses `s.bonus` (not `s.salary`), the type mismatch on `salary` should be irrelevant and no schema evolution should occur. Asserts both data and schema remain unchanged.
2. **Error for incompatible cross-column assignment**: `UPDATE SET salary = s.bonus` where `s.bonus` is STRING and `target.salary` is INT. This should fail regardless of schema evolution because the explicit assignment has incompatible types.
### Why are the changes needed?
These tests cover a gap in schema evolution test coverage. The existing tests for cross-column assignments (`salary = s.bonus`) did not include the scenario where the source also has a same-named column (`salary`) with a different type. This is important to verify that schema evolution correctly considers only the actual assignment columns, not unrelated same-named columns with wider types.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
New tests added and run via:
```
build/sbt 'sql/testOnly *GroupBasedMergeIntoSchemaEvolutionSQLSuite -- -z "type mismatch on existing column"'
```
All 4 test cases pass (2 tests x 2 variants: with/without evolution clause).
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Cursor (Claude claude-4.6-opus-high-thinking)
Closes #55173 from szehon-ho/SPARK-56343.
Authored-by: Szehon Ho <szehon.apache@gmail.com>
Signed-off-by: Anton Okolnychyi <aokolnychyi@apache.org>1 parent 33c18ee commit efa725e
File tree
1 file changed
+88
-0
lines changed- sql/core/src/test/scala/org/apache/spark/sql/connector
1 file changed
+88
-0
lines changedLines changed: 88 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
147 | 235 | | |
148 | 236 | | |
149 | 237 | | |
| |||
0 commit comments