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

Commit

Permalink
implement rlike/regexp_like (#938)
Browse files Browse the repository at this point in the history
This patch implements rlike/regexp_like

Signed-off-by: Yuan Zhou <[email protected]>
  • Loading branch information
zhouyuan authored Jun 1, 2022
1 parent 77e3b5c commit 1ab60c7
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,33 @@ class ColumnarLike(left: Expression, right: Expression, original: Expression)
}
}

class ColumnarRLike(left: Expression, right: Expression, original: Expression)
extends RLike(left: Expression, right: Expression)
with ColumnarExpression
with Logging {

buildCheck()

def buildCheck(): Unit = {
if (!right.isInstanceOf[Literal]) {
throw new UnsupportedOperationException(
s"Gandiva 'like' function requires a literal as the second parameter.")
}
}

override def doColumnarCodeGen(args: java.lang.Object): (TreeNode, ArrowType) = {
val (left_node, left_type): (TreeNode, ArrowType) =
left.asInstanceOf[ColumnarExpression].doColumnarCodeGen(args)
val (right_node, right_type): (TreeNode, ArrowType) =
right.asInstanceOf[ColumnarExpression].doColumnarCodeGen(args)

val resultType = new ArrowType.Bool()
val funcNode =
TreeBuilder.makeFunction("like", Lists.newArrayList(left_node, right_node), resultType)
(funcNode, resultType)
}
}

class ColumnarContains(left: Expression, right: Expression, original: Expression)
extends Contains(left: Expression, right: Expression)
with ColumnarExpression
Expand Down Expand Up @@ -507,6 +534,8 @@ object ColumnarBinaryOperator {
new ColumnarContains(left, right, c)
case l: Like =>
new ColumnarLike(left, right, l)
case rl: RLike =>
new ColumnarRLike(left, right, rl)
case s: ShiftLeft =>
new ColumnarShiftLeft(left, right, s)
case s: ShiftRight =>
Expand Down

0 comments on commit 1ab60c7

Please sign in to comment.