Github user mgaido91 commented on a diff in the pull request: https://github.com/apache/spark/pull/19728#discussion_r150579715 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala --- @@ -126,18 +143,41 @@ case class ConcatWs(children: Seq[Expression]) // All children are strings. In that case we can construct a fixed size array. val evals = children.map(_.genCode(ctx)) - val inputs = evals.map { eval => - s"${eval.isNull} ? (UTF8String) null : ${eval.value}" - }.mkString(", ") - - ev.copy(evals.map(_.code).mkString("\n") + s""" - UTF8String ${ev.value} = UTF8String.concatWs($inputs); + val argNums = evals.length --- End diff -- no, I am saying the opposite. Let's consider an example, maybe I better can explain what I mean in this way. Let's assume that we are running `concat_ws(',', 'a', 'b')`. Then, `evals` would contain 3 elements. So here your `argNums` would be 3. But [here](https://github.com/apache/spark/pull/19728/files/e6b73abf33216fe564ee59213877403cf137c3b4#diff-2eb730f0723800778689468764627032R149) you would be using only `$args[0]` and `$args[1]`, because the first element (`','`, the separator) is handled differently. Thus, I would suggest to have something like: ``` val sep = evals.head val strings = evals.tail val argNums = strings.length // note that this is evals.length -1 ... ``` I think that in this way the code would be much clearer (other than fixing this little bug).
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org