stwhit commented on a change in pull request #30189:
URL: https://github.com/apache/spark/pull/30189#discussion_r518813843



##########
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:
       I replaced outNullElem (which always appended " null") with 
appendIfNotLegacyCastToStr (which allows you to pass in the string to be 
appended).
   
   Because the map, struct, and array code all called the outNullElem function, 
I changed them all to call appendIfNotLegacyCastToStr, even though, in the case 
of map, I'm not actually changing its behavior.  IOW, the map code was already 
correct, so I'm not making any changes to its behavior, I only changed that 
function call because that function is shared with struct and array.
   
   This is also why I didn't add any unit tests for map.  I didn't change its 
behavior.
   
   How would you like me to resolve this?  I can put the outNullElem function 
back, and revert the map code to call it, which will revert all of my changes 
to the map code.  However, doing that will create what could be considered 
redundant code (both outNullElem and appendIfNotLegacyCastToStr do almost the 
same thing, and appendIfNotLegacyCastToStr supercedes outNullElem, rendering 
outNullElem redundant).
   
   I'm happy to make whatever change you recommend.  Please advise.




----------------------------------------------------------------
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]

Reply via email to