-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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
[SPARK-43063][SQL][FOLLOWUP] Add a space between ->
and value
#41432
Conversation
cc @cloud-fan , @yaooqinn , @LuciferYang |
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.
good catch!
Thank you! |
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.
Just wonder, don't we have any test to catch this?
@dongjoon-hyun Thanks for your catch, In fact, we've already fixed it here |
Merged to master. |
### What changes were proposed in this pull request? This is a follow-up of apache#40922. This PR aims to add a space between `->` and value. It seems to be missed here because the original PR already have the same code pattern in other place. https://github.com/apache/spark/blob/74b04eeffdc4765f56fe3a9e97165b15ed4e2c73/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/ToStringBase.scala#L114 ### Why are the changes needed? **BEFORE** ``` scala> sql("select map('k', null)").show() +------------+ |map(k, NULL)| +------------+ | {k ->NULL}| +------------+ ``` **AFTER** ``` scala> sql("select map('k', null)").show() +------------+ |map(k, NULL)| +------------+ | {k -> NULL}| +------------+ ``` ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Manual review. Closes apache#41432 from dongjoon-hyun/SPARK-43063. Authored-by: Dongjoon Hyun <dongjoon@apache.org> Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
@@ -100,7 +100,7 @@ trait ToStringBase { self: UnaryExpression with TimeZoneAwareExpression => | |||
builder.append(keyToUTF8String(keyArray.get(0, kt)).asInstanceOf[UTF8String]) | |||
builder.append(" ->") | |||
if (valueArray.isNullAt(0)) { | |||
if (nullString.nonEmpty) builder.append(nullString) | |||
if (nullString.nonEmpty) builder.append(" " + nullString) |
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.
does the codegen have the same bug?
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.
…rst value is null As noted by cloud-fan #41432 (comment), #41432 fixed a formatting issue when casting map to string but did not fix it in the codegen case. This PR fixes the issue and updates a unit test to test the codegen path. Without the fix, the test fails with: ``` - SPARK-22973 Cast map to string *** FAILED *** Incorrect evaluation (fallback mode = CODEGEN_ONLY): cast(map(keys: [1,2,3], values: [null,[B5c3fd9f3,[B70f84210]) as string), actual: {1 ->null, 2 -> a, 3 -> c}, expected: {1 -> null, 2 -> a, 3 -> c} (ExpressionEvalHelper.scala:270) ``` Closes #42434 from andygrove/space-before-null-cast-codegen. Authored-by: Andy Grove <andygrove73@gmail.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
…rst value is null As noted by cloud-fan #41432 (comment), #41432 fixed a formatting issue when casting map to string but did not fix it in the codegen case. This PR fixes the issue and updates a unit test to test the codegen path. Without the fix, the test fails with: ``` - SPARK-22973 Cast map to string *** FAILED *** Incorrect evaluation (fallback mode = CODEGEN_ONLY): cast(map(keys: [1,2,3], values: [null,[B5c3fd9f3,[B70f84210]) as string), actual: {1 ->null, 2 -> a, 3 -> c}, expected: {1 -> null, 2 -> a, 3 -> c} (ExpressionEvalHelper.scala:270) ``` Closes #42434 from andygrove/space-before-null-cast-codegen. Authored-by: Andy Grove <andygrove73@gmail.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com> (cherry picked from commit 7e52169) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
…rst value is null As noted by cloud-fan apache#41432 (comment), apache#41432 fixed a formatting issue when casting map to string but did not fix it in the codegen case. This PR fixes the issue and updates a unit test to test the codegen path. Without the fix, the test fails with: ``` - SPARK-22973 Cast map to string *** FAILED *** Incorrect evaluation (fallback mode = CODEGEN_ONLY): cast(map(keys: [1,2,3], values: [null,[B5c3fd9f3,[B70f84210]) as string), actual: {1 ->null, 2 -> a, 3 -> c}, expected: {1 -> null, 2 -> a, 3 -> c} (ExpressionEvalHelper.scala:270) ``` Closes apache#42434 from andygrove/space-before-null-cast-codegen. Authored-by: Andy Grove <andygrove73@gmail.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
…rst value is null As noted by cloud-fan apache#41432 (comment), apache#41432 fixed a formatting issue when casting map to string but did not fix it in the codegen case. This PR fixes the issue and updates a unit test to test the codegen path. Without the fix, the test fails with: ``` - SPARK-22973 Cast map to string *** FAILED *** Incorrect evaluation (fallback mode = CODEGEN_ONLY): cast(map(keys: [1,2,3], values: [null,[B5c3fd9f3,[B70f84210]) as string), actual: {1 ->null, 2 -> a, 3 -> c}, expected: {1 -> null, 2 -> a, 3 -> c} (ExpressionEvalHelper.scala:270) ``` Closes apache#42434 from andygrove/space-before-null-cast-codegen. Authored-by: Andy Grove <andygrove73@gmail.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
What changes were proposed in this pull request?
This is a follow-up of #40922. This PR aims to add a space between
->
and value.It seems to be missed here because the original PR already have the same code pattern in other place.
spark/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/ToStringBase.scala
Line 114 in 74b04ee
Why are the changes needed?
BEFORE
AFTER
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Manual review.