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

[NSE-1053] Support function in substring's pos and len #1054

Merged
merged 2 commits into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,14 +56,22 @@ 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)

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)
// FIXME(): gandiva only support pos and len with int64 type
val long_pos_node = pos match {
jackylee-ch marked this conversation as resolved.
Show resolved Hide resolved
case literal: ColumnarLiteral =>
TreeBuilder.makeLiteral(literal.value.asInstanceOf[Integer].longValue() : java.lang.Long)
case _ =>
TreeBuilder.makeFunction(
"castBIGINT", Lists.newArrayList(pos_node), new ArrowType.Int(64, true))
}

val long_len_node = len match {
case literal: ColumnarLiteral =>
TreeBuilder.makeLiteral(literal.value.asInstanceOf[Integer].longValue() : java.lang.Long)
case _ =>
TreeBuilder.makeFunction(
"castBIGINT", Lists.newArrayList(len_node), new ArrowType.Int(64, true))
}

val resultType = new ArrowType.Utf8()
val funcNode =
Expand Down