Skip to content

Commit

Permalink
Fix logic of condition separation and refactor (facebookincubator#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
rui-mo authored and zhejiangxiaomai committed Mar 29, 2023
1 parent 4c480c9 commit 5061adf
Show file tree
Hide file tree
Showing 4 changed files with 251 additions and 177 deletions.
7 changes: 5 additions & 2 deletions velox/substrait/SubstraitToVeloxExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,14 @@ 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];
// TODO: other options?
auto inLists = singularOrList.options();
VELOX_CHECK(inLists.size() > 0, "At least one option is needed.");
params.reserve(2);
// first is the value, second is the list
params.emplace_back(toVeloxExpr(singularOrList.value(), inputType));
params.emplace_back(toVeloxExpr(*inLists, inputType));
// TODO: is this the correct way to use SingularOrList?
params.emplace_back(toVeloxExpr(inLists[0], inputType));
return std::make_shared<const core::CallTypedExpr>(
BOOLEAN(), std::move(params), "in");
}
Expand Down
1 change: 1 addition & 0 deletions velox/substrait/SubstraitToVeloxExpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class SubstraitVeloxExprConverter {
const ::substrait::Expression::ScalarFunction& sFunc,
const RowTypePtr& inputType);

/// Convert Substrait SingularOrList into Velox Expression.
core::TypedExprPtr toVeloxExpr(
const ::substrait::Expression::SingularOrList& singularOrList,
const RowTypePtr& inputType);
Expand Down
Loading

0 comments on commit 5061adf

Please sign in to comment.