stwhit commented on a change in pull request #30189:
URL: https://github.com/apache/spark/pull/30189#discussion_r518902804
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
##########
@@ -982,7 +985,7 @@ abstract class CastBase extends UnaryExpression with
TimeZoneAwareExpression wit
| $buffer.append($keyToStringFunc($getMapFirstKey));
| $buffer.append(" ->");
| if ($map.valueArray().isNullAt(0)) {
- | ${outNullElem(buffer)}
+ | ${appendIfNotLegacyCastToStr(buffer, " null")}
Review comment:
map's behavior is already correct. For example, when printing a map, it
looks like this:
{A -> B, C -> D}
So, the values are already printed with a leading space, as they should be.
Therefore, I didn't need to change map's behavior.
Regarding a unit test, one already exists. In CastSuite.scala, beginning on
line 731 (in my branch), there's a test named "SPARK-22973 Cast map to string"
which already exists. So, yes, I changed map's code, but no, I didn't change
map's behavior, and the correct map behavior is already being unit tested. My
code changes didn't change the behavior, and the existing unit test passes
successfully after my changes.
I could add another unit test, but it will literally just be the same as the
existing unit test (because I didn't change any behavior). Do you want me to
go ahead and add another unit test?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]