Commit ec7570e
[SPARK-49275][SQL] Fix return type nullness of the xpath expression
### What changes were proposed in this pull request?
The `xpath` expression incorrectly marks its return type as array of non-null strings. However, it can actually return an array containing nulls. This can cause NPE in code generation, such as query `select coalesce(xpath(repeat('<a></a>', id), 'a')[0], '') from range(1, 2)`.
### Why are the changes needed?
It avoids potential failures in queries that uses the `xpath` expression.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
A new unit test. It would fail without the change in the PR.
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes #47796 from chenhao-db/fix_xpath_nullness.
Authored-by: Chenhao Li <[email protected]>
Signed-off-by: Max Gekk <[email protected]>1 parent c274c5a commit ec7570e
File tree
2 files changed
+8
-1
lines changed- sql/catalyst/src
- main/scala/org/apache/spark/sql/catalyst/expressions/xml
- test/scala/org/apache/spark/sql/catalyst/expressions/xml
2 files changed
+8
-1
lines changedLines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
| 245 | + | |
| 246 | + | |
245 | 247 | | |
246 | 248 | | |
247 | 249 | | |
248 | 250 | | |
249 | 251 | | |
250 | 252 | | |
251 | | - | |
| 253 | + | |
252 | 254 | | |
253 | 255 | | |
254 | 256 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
188 | 193 | | |
189 | 194 | | |
190 | 195 | | |
| |||
0 commit comments