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

Commit

Permalink
[NSE-955] Support find_in_set function (#1042)
Browse files Browse the repository at this point in the history
* Initial commit

* Change arrow branch [will revert at last]

* Revert "Change arrow branch [will revert at last]"

This reverts commit 545b1b4.
  • Loading branch information
PHILO-HE authored Jul 25, 2022
1 parent 50ef3d1 commit 40a853e
Showing 1 changed file with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -507,9 +507,9 @@ class ColumnarShiftRight(left: Expression, right: Expression, original: Expressi
with ColumnarExpression
with Logging {
override def doColumnarCodeGen(args: Object): (TreeNode, ArrowType) = {
var (left_node, left_type): (TreeNode, ArrowType) =
val (left_node, left_type): (TreeNode, ArrowType) =
left.asInstanceOf[ColumnarExpression].doColumnarCodeGen(args)
var (right_node, right_type): (TreeNode, ArrowType) =
val (right_node, right_type): (TreeNode, ArrowType) =
right.asInstanceOf[ColumnarExpression].doColumnarCodeGen(args)

if (right_type.getTypeID != ArrowTypeID.Int) {
Expand All @@ -524,6 +524,26 @@ class ColumnarShiftRight(left: Expression, right: Expression, original: Expressi
}
}

class ColumnarFindInSet(left: Expression, right: Expression, original: Expression)
extends FindInSet(left: Expression, right: Expression) with ColumnarExpression with Logging {

override def supportColumnarCodegen(args: Object): Boolean = {
false
}

override def doColumnarCodeGen(args: Object): (TreeNode, ArrowType) = {
val (leftNode, _): (TreeNode, ArrowType) =
left.asInstanceOf[ColumnarExpression].doColumnarCodeGen(args)
val (rightNode, _): (TreeNode, ArrowType) =
right.asInstanceOf[ColumnarExpression].doColumnarCodeGen(args)

val resultType = new ArrowType.Int(32, true)
val funcNode = TreeBuilder.makeFunction("find_in_set",
Lists.newArrayList(leftNode, rightNode), resultType)
(funcNode, resultType)
}
}

object ColumnarBinaryOperator {

def create(left: Expression, right: Expression, original: Expression): Expression = {
Expand Down Expand Up @@ -559,6 +579,8 @@ object ColumnarBinaryOperator {
new ColumnarShiftLeft(left, right, s)
case s: ShiftRight =>
new ColumnarShiftRight(left, right, s)
case f: FindInSet =>
new ColumnarFindInSet(left, right, f)
case other =>
throw new UnsupportedOperationException(s"not currently supported: $other.")
}
Expand Down

0 comments on commit 40a853e

Please sign in to comment.