Skip to content

Commit

Permalink
[OPPRO-233] Add SingularOrList support (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
jinchengchenghh authored and zhejiangxiaomai committed Nov 7, 2022
1 parent 8f8f1ef commit ab13751
Show file tree
Hide file tree
Showing 4 changed files with 278 additions and 166 deletions.
13 changes: 13 additions & 0 deletions velox/substrait/SubstraitToVeloxExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,19 @@ SubstraitVeloxExprConverter::toVeloxExpr(
toVeloxType(typeName), std::move(params), veloxFunction);
}

core::TypedExprPtr SubstraitVeloxExprConverter::toVeloxExpr(
const ::substrait::Expression::SingularOrList& singularOrList,
const RowTypePtr& inputType) {
std::vector<std::shared_ptr<const core::ITypedExpr>> params;
auto inLists = singularOrList.options().data()[0];
params.reserve(2);
// first is the value, second is the list
params.emplace_back(toVeloxExpr(singularOrList.value(), inputType));
params.emplace_back(toVeloxExpr(*inLists, inputType));
return std::make_shared<const core::CallTypedExpr>(
BOOLEAN(), std::move(params), "in");
}

std::shared_ptr<const core::ConstantTypedExpr>
SubstraitVeloxExprConverter::toVeloxExpr(
const ::substrait::Expression::Literal& substraitLit) {
Expand Down
4 changes: 4 additions & 0 deletions velox/substrait/SubstraitToVeloxExpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ class SubstraitVeloxExprConverter {
const ::substrait::Expression::ScalarFunction& sFunc,
const RowTypePtr& inputType);

core::TypedExprPtr toVeloxExpr(
const ::substrait::Expression::SingularOrList& singularOrList,
const RowTypePtr& inputType);

/// Convert Substrait CastExpression to Velox Expression.
std::shared_ptr<const core::ITypedExpr> toVeloxExpr(
const ::substrait::Expression::Cast& castExpr,
Expand Down
Loading

0 comments on commit ab13751

Please sign in to comment.