Github user davies commented on a diff in the pull request:

    https://github.com/apache/spark/pull/8353#discussion_r37658342
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala
 ---
    @@ -114,8 +114,41 @@ case class ConcatWs(children: Seq[Expression])
             boolean ${ev.isNull} = ${ev.primitive} == null;
           """
         } else {
    -      // Contains a mix of strings and array<string>s. Fall back to 
interpreted mode for now.
    -      super.genCode(ctx, ev)
    +      val list = ctx.freshName("list")
    +      val array = ctx.freshName("array")
    +
    +      val sep = children.head.gen(ctx)
    +      val vararg = children.tail.map { child =>
    +        val eval = child.gen(ctx)
    +        child.dataType match {
    +          case StringType =>
    +            s"""
    +              ${eval.code}
    +              $list.add(${eval.isNull} ? (UTF8String) null : 
${eval.primitive});
    +             """
    +          case _: ArrayType =>
    +            val size = ctx.freshName("n")
    +            val j = ctx.freshName("j")
    +            s"""
    +              ${eval.code}
    +              if (!${eval.isNull}) {
    +                final int $size = ${eval.primitive}.numElements();
    +                for (int $j = 0; $j < $size; $j ++) {
    --- End diff --
    
    Minor: `j` is only available in loop scope, so we don't need to create a 
unique name for it.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to