File tree Expand file tree Collapse file tree 1 file changed +26
-2
lines changed
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions Expand file tree Collapse file tree 1 file changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -114,8 +114,32 @@ case class ConcatWs(children: Seq[Expression])
114114 boolean ${ev.isNull} = ${ev.primitive} == null;
115115 """
116116 } else {
117- // Contains a mix of strings and array<string>s. Fall back to interpreted mode for now.
118- super .genCode(ctx, ev)
117+ val list = ctx.freshName(" list" )
118+ val array = ctx.freshName(" array" )
119+ val sep = children.head.gen(ctx)
120+ val argsCode = children.tail.map(x => {
121+ val gen = x.gen(ctx)
122+ if (x.dataType == StringType ) {
123+ s """
124+ ${gen.code}
125+ $list.add( ${gen.primitive});
126+ """
127+ } else {
128+ s """
129+ ${gen.code}
130+ $list.addAll(scala.collection.JavaConversions.asJavaCollection( ${gen.primitive}));
131+ """
132+ }
133+ }).foldLeft(" " )((a, b) => a + " \n " + b)
134+ s """
135+ ${sep.code}
136+ java.util.ArrayList<UTF8String> $list = new java.util.ArrayList<UTF8String>();
137+ $argsCode
138+ UTF8String[] $array = new UTF8String[ $list.size()];
139+ $list.toArray( $array);
140+ UTF8String ${ev.primitive} = UTF8String.concatWs( ${sep.primitive}, $array);
141+ boolean ${ev.isNull} = ${ev.primitive} == null;
142+ """
119143 }
120144 }
121145}
You can’t perform that action at this time.
0 commit comments