dongjoon-hyun commented on a change in pull request #31336:
URL: https://github.com/apache/spark/pull/31336#discussion_r564215741
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
##########
@@ -3957,13 +3957,16 @@ object ApplyCharTypePadding extends Rule[LogicalPlan] {
if attr.dataType == StringType && list.forall(_.foldable) =>
CharVarcharUtils.getRawType(attr.metadata).flatMap {
case CharType(length) =>
- val literalCharLengths =
list.map(_.eval().asInstanceOf[UTF8String].numChars())
- val targetLen = (length +: literalCharLengths).max
- Some(i.copy(
- value = addPadding(attr, length, targetLen),
- list = list.zip(literalCharLengths).map {
- case (lit, charLength) => addPadding(lit, charLength,
targetLen)
- }))
+ val (nulls, literalChars) =
+ list.map(_.eval().asInstanceOf[UTF8String]).partition(_ ==
null)
+ val literalCharLengths = literalChars.map(_.numChars())
+ val targetLen = literalCharLengths.fold(length)(_ max _)
+
+ val newAttr = addPadding(attr, length, targetLen)
+ val newList = list.zip(literalCharLengths).map {
Review comment:
Is this change required?
----------------------------------------------------------------
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]