Skip to content

Commit

Permalink
[OPPRO-233] Add SingularOrList support (oap-project#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
jinchengchenghh authored and zhejiangxiaomai committed Sep 22, 2022
1 parent 366f060 commit a57a872
Show file tree
Hide file tree
Showing 4 changed files with 281 additions and 166 deletions.
16 changes: 16 additions & 0 deletions velox/substrait/SubstraitToVeloxExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,20 @@ 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 Expand Up @@ -272,6 +286,8 @@ SubstraitVeloxExprConverter::toVeloxExpr(
return toVeloxExpr(sExpr.cast(), inputType);
case ::substrait::Expression::RexTypeCase::kIfThen:
return toVeloxExpr(sExpr.if_then(), inputType);
case ::substrait::Expression::RexTypeCase::kSingularOrList:
return toVeloxExpr(sExpr.singular_or_list(), inputType);
default:
VELOX_NYI(
"Substrait conversion not supported for Expression '{}'", typeCase);
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 a57a872

Please sign in to comment.