-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-49476][SQL] Fix nullability of base64 function #47941
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
Conversation
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.
LGTM except of a comment.
Please, append the [SQL] tag in PR's title.
| assert(!Base64(Literal(bytes)).nullable) | ||
| assert(Base64(Literal.create(null, BinaryType)).nullable) | ||
| assert(!UnBase64(Literal("AQIDBA==")).nullable) | ||
| assert(UnBase64(Literal.create(null, StringType)).nullable) |
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.
Let's add a check when you pass non-NULL expr but mark it as a nullable:
assert(Base64(Literal(bytes).castNullable()).nullable)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.
Added
| assert(UnBase64(Literal.create(null, StringType)).nullable) | ||
| assert(UnBase64(Literal("AQIDBA==").castNullable()).nullable) | ||
|
|
||
|
|
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.
nit: Adding one blank line here is enough
...talyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/StringExpressionsSuite.scala
Outdated
Show resolved
Hide resolved
…essions/StringExpressionsSuite.scala
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.
+1, LGTM. Merging to master/3.5.
Thank you, @Kimahriman and @LuciferYang @yaooqinn for review.
### What changes were proposed in this pull request? Fix the nullability of the `Base64` expression to be based on the child's nullability, and not always be nullable. ### Why are the changes needed? #47303 had a side effect of changing the nullability by the switch to using `StaticInvoke`. This was also backported to Spark 3.5.2 and caused schema mismatch errors for stateful streams when we upgraded. This restores the previous behavior which is supported by StaticInvoke through the `returnNullable` argument. If the child is non-nullable, we know the result will be non-nullable. ### Does this PR introduce _any_ user-facing change? Restores the nullability of the `Base64` expression to what is was in Spark 3.5.1 and earlier. ### How was this patch tested? New UT ### Was this patch authored or co-authored using generative AI tooling? No Closes #47941 from Kimahriman/base64-nullability. Lead-authored-by: Adam Binford <[email protected]> Co-authored-by: Maxim Gekk <[email protected]> Signed-off-by: Max Gekk <[email protected]> (cherry picked from commit c274c5a) Signed-off-by: Max Gekk <[email protected]>
|
Made a follow up to fix a test in the 3.5 backport #47964 |
### What changes were proposed in this pull request? Fix a test that is failing from backporting #47941 ### Why are the changes needed? Fix test ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Fixed test ### Was this patch authored or co-authored using generative AI tooling? No Closes #47964 from Kimahriman/base64-proto-test. Authored-by: Adam Binford <[email protected]> Signed-off-by: Kent Yao <[email protected]>
|
Thank you, @Kimahriman and all. |
* [SPARK-49476][SQL] Fix nullability of base64 function ### What changes were proposed in this pull request? Fix the nullability of the `Base64` expression to be based on the child's nullability, and not always be nullable. ### Why are the changes needed? apache#47303 had a side effect of changing the nullability by the switch to using `StaticInvoke`. This was also backported to Spark 3.5.2 and caused schema mismatch errors for stateful streams when we upgraded. This restores the previous behavior which is supported by StaticInvoke through the `returnNullable` argument. If the child is non-nullable, we know the result will be non-nullable. ### Does this PR introduce _any_ user-facing change? Restores the nullability of the `Base64` expression to what is was in Spark 3.5.1 and earlier. ### How was this patch tested? New UT ### Was this patch authored or co-authored using generative AI tooling? No Closes apache#47941 from Kimahriman/base64-nullability. Lead-authored-by: Adam Binford <[email protected]> Co-authored-by: Maxim Gekk <[email protected]> Signed-off-by: Max Gekk <[email protected]> (cherry picked from commit c274c5a) Signed-off-by: Max Gekk <[email protected]> * [SPARK-49476][SQL][3.5][FOLLOWUP] Fix base64 proto test ### What changes were proposed in this pull request? Fix a test that is failing from backporting apache#47941 ### Why are the changes needed? Fix test ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Fixed test ### Was this patch authored or co-authored using generative AI tooling? No Closes apache#47964 from Kimahriman/base64-proto-test. Authored-by: Adam Binford <[email protected]> Signed-off-by: Kent Yao <[email protected]> * [SPARK-49476][SQL][3.5][FOLLOWUP] Fix base64 proto test ### What changes were proposed in this pull request? Fix a test that is failing from backporting apache#47941 ### Why are the changes needed? Fix test ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Fixed test ### Was this patch authored or co-authored using generative AI tooling? No Closes apache#47964 from Kimahriman/base64-proto-test. Authored-by: Adam Binford <[email protected]> Signed-off-by: Kent Yao <[email protected]> --------- Signed-off-by: Max Gekk <[email protected]> Signed-off-by: Kent Yao <[email protected]> Co-authored-by: Adam Binford <[email protected]> Co-authored-by: Maxim Gekk <[email protected]>
What changes were proposed in this pull request?
Fix the nullability of the
Base64expression to be based on the child's nullability, and not always be nullable.Why are the changes needed?
#47303 had a side effect of changing the nullability by the switch to using
StaticInvoke. This was also backported to Spark 3.5.2 and caused schema mismatch errors for stateful streams when we upgraded. This restores the previous behavior which is supported by StaticInvoke through thereturnNullableargument. If the child is non-nullable, we know the result will be non-nullable.Does this PR introduce any user-facing change?
Restores the nullability of the
Base64expression to what is was in Spark 3.5.1 and earlier.How was this patch tested?
New UT
Was this patch authored or co-authored using generative AI tooling?
No