Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

Commit

Permalink
fix logic
Browse files Browse the repository at this point in the history
Signed-off-by: Yuan Zhou <[email protected]>
  • Loading branch information
zhouyuan committed Jun 13, 2022
1 parent 8601dc8 commit 761db9f
Showing 1 changed file with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,41 +50,39 @@ class ColumnarConcatWs(exps: Seq[Expression], original: Expression)

override def doColumnarCodeGen(args: java.lang.Object): (TreeNode, ArrowType) = {
val iter: Iterator[Expression] = exps.iterator
val exp = iter.next()
val exp = iter.next() // spliter
val exp1 = iter.next()
val iterFaster: Iterator[Expression] = exps.iterator
iterFaster.next()
iterFaster.next()
iterFaster.next()

val (exp_node, expType): (TreeNode, ArrowType) =
val (split_node, expType): (TreeNode, ArrowType) =
exp.asInstanceOf[ColumnarExpression].doColumnarCodeGen(args)
val (exp1_node, exp1Type): (TreeNode, ArrowType) =
exp1.asInstanceOf[ColumnarExpression].doColumnarCodeGen(args)

val resultType = new ArrowType.Utf8()
//concat_ws is null senstive
val funcNode = TreeBuilder.makeFunction("concat",
Lists.newArrayList(exp_node, rightNode(args, exp, exps, iter, iterFaster)), resultType)
Lists.newArrayList(exp1_node, split_node, rightNode(args, exps, split_node, iter, iterFaster)), resultType)
(funcNode, expType)
}

def rightNode(args: java.lang.Object, head: Expression, exps: Seq[Expression],
def rightNode(args: java.lang.Object, exps: Seq[Expression], split_node: TreeNode,
iter: Iterator[Expression], iterFaster: Iterator[Expression]): TreeNode = {
if (!iterFaster.hasNext) {
// When iter reaches the last but one expression
val (exp_node, expType): (TreeNode, ArrowType) =
exps.last.asInstanceOf[ColumnarExpression].doColumnarCodeGen(args)
val (head_node, headType): (TreeNode, ArrowType) =
head.asInstanceOf[ColumnarExpression].doColumnarCodeGen(args)
val resultType = new ArrowType.Utf8()
val funcNode = TreeBuilder.makeFunction("concat",
Lists.newArrayList(head_node, exp_node), resultType)
funcNode
exp_node
} else {
val exp = iter.next()
iterFaster.next()
val (exp_node, expType): (TreeNode, ArrowType) =
exp.asInstanceOf[ColumnarExpression].doColumnarCodeGen(args)
val resultType = new ArrowType.Utf8()
val funcNode = TreeBuilder.makeFunction("concat",
Lists.newArrayList(exp_node, rightNode(args, head, exps, iter, iterFaster)), resultType)
Lists.newArrayList(exp_node, split_node, rightNode(args, exps, split_node, iter, iterFaster)), resultType)
funcNode
}
}
Expand Down

0 comments on commit 761db9f

Please sign in to comment.