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

Commit

Permalink
[NSE-1053] Support non-literal expression for substring's pos and len (
Browse files Browse the repository at this point in the history
…#1054)

* support function in substring

* remove extra match
  • Loading branch information
jackylee-ch authored Jul 29, 2022
1 parent 4ae575d commit 2479200
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,11 @@ object ColumnarExpressionConverter extends Logging {
convertBoundRefToAttrRef = convertBoundRefToAttrRef),
replaceWithColumnarExpression(
ss.pos,
attributeSeq,
convertBoundRefToAttrRef = convertBoundRefToAttrRef),
replaceWithColumnarExpression(
ss.len,
attributeSeq,
convertBoundRefToAttrRef = convertBoundRefToAttrRef),
expr)
case st: StringTranslate =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,16 @@ class ColumnarSubString(str: Expression, pos: Expression, len: Expression, origi
val (len_node, lenType): (TreeNode, ArrowType) =
len.asInstanceOf[ColumnarExpression].doColumnarCodeGen(args)

//FIXME(): gandiva only support pos and len with int64 type
val lit_pos :ColumnarLiteral= pos.asInstanceOf[ColumnarLiteral]
val lit_pos_val = lit_pos.value
val long_pos_node = TreeBuilder.makeLiteral(lit_pos_val.asInstanceOf[Integer].longValue() :java.lang.Long)
// FIXME(): gandiva only support pos and len with int64 type
val long_pos_node = TreeBuilder.makeFunction(
"castBIGINT", Lists.newArrayList(pos_node), new ArrowType.Int(64, true))

val lit_len :ColumnarLiteral= len.asInstanceOf[ColumnarLiteral]
val lit_len_val = lit_len.value
val long_len_node = TreeBuilder.makeLiteral(lit_len_val.asInstanceOf[Integer].longValue() :java.lang.Long)
val long_len_node = TreeBuilder.makeFunction(
"castBIGINT", Lists.newArrayList(len_node), new ArrowType.Int(64, true))

val resultType = new ArrowType.Utf8()
val funcNode =
TreeBuilder.makeFunction("substr", Lists.newArrayList(str_node, long_pos_node, long_len_node), resultType)
val funcNode = TreeBuilder.makeFunction(
"substr", Lists.newArrayList(str_node, long_pos_node, long_len_node), resultType)
(funcNode, resultType)
}
}
Expand Down

0 comments on commit 2479200

Please sign in to comment.