-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-49275][SQL][3.5] Fix return type nullness of the xpath expression #47959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]>
Contributor
Author
|
@MaxGekk here is the PR for 3.5. |
MaxGekk
requested changes
Sep 3, 2024
Member
MaxGekk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chenhao-db Could you fix the test failure:
- function_base64 *** FAILED *** (6 milliseconds)
[info] Expected and actual plans do not match:
[info]
[info] === Expected Plan ===
[info] Project [staticinvoke(class org.apache.spark.sql.catalyst.expressions.Base64, StringType, encode, cast(g#0 as binary), true, BinaryType, BooleanType, true, true, true) AS base64(g)#0]
[info] +- LocalRelation <empty>, [id#0L, a#0, b#0, d#0, e#0, f#0, g#0]
[info]
[info]
[info] === Actual Plan ===
[info] Project [staticinvoke(class org.apache.spark.sql.catalyst.expressions.Base64, StringType, encode, cast(g#0 as binary), true, BinaryType, BooleanType, true, false, true) AS base64(g)#0]
Contributor
Author
|
@MaxGekk Done. There is actually nothing wrong with my code, but |
MaxGekk
approved these changes
Sep 4, 2024
Member
|
+1, LGTM. Merging to 3.5. |
MaxGekk
pushed a commit
that referenced
this pull request
Sep 4, 2024
### What changes were proposed in this pull request? This is a cherry-pick of #47796. 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 #47959 from chenhao-db/fix_xpath_nullness_3.5. Authored-by: Chenhao Li <[email protected]> Signed-off-by: Max Gekk <[email protected]>
turboFei
pushed a commit
to turboFei/spark
that referenced
this pull request
Nov 6, 2025
…ion (apache#556) ### What changes were proposed in this pull request? This is a cherry-pick of apache#47796. 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 apache#47959 from chenhao-db/fix_xpath_nullness_3.5. Authored-by: Chenhao Li <[email protected]> Signed-off-by: Max Gekk <[email protected]> Co-authored-by: Chenhao Li <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
This is a cherry-pick of #47796.
The
xpathexpression 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 queryselect 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
xpathexpression.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.