@@ -63,7 +63,6 @@ case class Concat(children: Seq[Expression]) extends Expression with ImplicitCas
6363
6464 override protected def doGenCode (ctx : CodegenContext , ev : ExprCode ): ExprCode = {
6565 val evals = children.map(_.genCode(ctx))
66- val numArgs = evals.length
6766 val args = ctx.freshName(" args" )
6867
6968 val inputs = evals.zipWithIndex.map { case (eval, index) =>
@@ -81,7 +80,7 @@ case class Concat(children: Seq[Expression]) extends Expression with ImplicitCas
8180 inputs.mkString(" \n " )
8281 }
8382 ev.copy(s """
84- UTF8String[] $args = new UTF8String[ $numArgs ];
83+ UTF8String[] $args = new UTF8String[ ${evals.length} ];
8584 $codes
8685 UTF8String ${ev.value} = UTF8String.concat( $args);
8786 boolean ${ev.isNull} = ${ev.value} == null;
@@ -140,7 +139,7 @@ case class ConcatWs(children: Seq[Expression])
140139 val evals = children.map(_.genCode(ctx))
141140 val separator = evals.head
142141 val strings = evals.tail
143- val argNums = strings.length
142+ val numArgs = strings.length
144143 val args = ctx.freshName(" args" )
145144
146145 val inputs = strings.zipWithIndex.map { case (eval, index) =>
@@ -155,15 +154,15 @@ case class ConcatWs(children: Seq[Expression])
155154 " "
156155 }
157156 }
158- val codes = s " ${separator.code}\n " +
159- (if (ctx.INPUT_ROW != null && ctx.currentVars == null ) {
160- ctx.splitExpressions(inputs, " valueConcatWs" ,
161- (" InternalRow" , ctx.INPUT_ROW ) :: (" UTF8String[]" , args) :: Nil )
162- } else {
163- inputs.mkString(" \n " )
164- })
157+ val codes = if (ctx.INPUT_ROW != null && ctx.currentVars == null ) {
158+ ctx.splitExpressions(inputs, " valueConcatWs" ,
159+ (" InternalRow" , ctx.INPUT_ROW ) :: (" UTF8String[]" , args) :: Nil )
160+ } else {
161+ inputs.mkString(" \n " )
162+ }
165163 ev.copy(s """
166- UTF8String[] $args = new UTF8String[ $argNums];
164+ UTF8String[] $args = new UTF8String[ $numArgs];
165+ ${separator.code}
167166 $codes
168167 UTF8String ${ev.value} = UTF8String.concatWs( ${separator.value}, $args);
169168 boolean ${ev.isNull} = ${ev.value} == null;
0 commit comments