Commit 79065ac
committed
[SPARK-49275][SQL] Fix return type nullness of the xpath expression
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)`.
It avoids potential failures in queries that uses the `xpath` expression.
No.
A new unit test. It would fail without the change in the PR.
No.
Closes apache#47796 from chenhao-db/fix_xpath_nullness.
Authored-by: Chenhao Li <[email protected]>
Signed-off-by: Max Gekk <[email protected]>1 parent 38ad0e7 commit 79065ac
File tree
2 files changed
+9
-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
+9
-1
lines changedLines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
| 242 | + | |
| 243 | + | |
242 | 244 | | |
243 | 245 | | |
244 | 246 | | |
245 | 247 | | |
246 | 248 | | |
247 | 249 | | |
248 | | - | |
| 250 | + | |
| 251 | + | |
249 | 252 | | |
250 | 253 | | |
251 | 254 | | |
| |||
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