Skip to content
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

Closed
wants to merge 1 commit into from
Closed

[SPARK-43063][SQL][FOLLOWUP] Add a space between -> and value #41432

wants to merge 1 commit into from

Conversation

dongjoon-hyun
Copy link
Member

@dongjoon-hyun dongjoon-hyun commented Jun 2, 2023

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.

if (nullString.nonEmpty) builder.append(" " + nullString)

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.

@dongjoon-hyun
Copy link
Member Author

cc @cloud-fan , @yaooqinn , @LuciferYang

Copy link
Contributor

@cloud-fan cloud-fan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch!

@dongjoon-hyun
Copy link
Member Author

Thank you!

Copy link
Member

@MaxGekk MaxGekk left a 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?

@yikf
Copy link
Contributor

yikf commented Jun 2, 2023

@dongjoon-hyun Thanks for your catch, In fact, we've already fixed it here

@HyukjinKwon
Copy link
Member

Merged to master.

czxm pushed a commit to czxm/spark that referenced this pull request Jun 12, 2023
### 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)
Copy link
Contributor

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?

Copy link
Member

@andygrove andygrove Aug 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it does. Proposed fix here: #42433 #42434

cloud-fan pushed a commit that referenced this pull request Aug 15, 2023
…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>
cloud-fan pushed a commit that referenced this pull request Aug 15, 2023
…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>
valentinp17 pushed a commit to valentinp17/spark that referenced this pull request Aug 24, 2023
…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>
ragnarok56 pushed a commit to ragnarok56/spark that referenced this pull request Mar 2, 2024
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
9 participants