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 16, 2022
1 parent f9d4cf2 commit 41d22ba
Show file tree
Hide file tree
Showing 4 changed files with 313 additions and 181 deletions.
16 changes: 16 additions & 0 deletions velox/substrait/SubstraitToVeloxExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,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 @@ -279,6 +293,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 41d22ba

Please sign in to comment.