Skip to content

Commit

Permalink
fix lookup index selection
Browse files Browse the repository at this point in the history
  • Loading branch information
czpmango committed Nov 18, 2022
1 parent 3dab844 commit a2c4241
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/graph/optimizer/rule/OptimizeTagIndexScanByFilterRule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,16 @@ StatusOr<TransformResult> OptimizeTagIndexScanByFilterRule::transform(
auto inExpr = static_cast<RelationalExpression*>(operand);
// Do not apply this rule if the IN expr has a valid index or it has more than 1 element in
// the list
if (static_cast<ListExpression*>(inExpr->right())->size() > 1) {
auto* rhs = inExpr->right();
if (rhs->isContainerExpr() &&
graph::ExpressionUtils::getContainerExprOperands(rhs).size() > 1) {
return TransformResult::noTransform();
} else if (rhs->kind() == Expression::Kind::kConstant) {
auto constExprValue = static_cast<const ConstantExpression*>(rhs)->value();
if ((constExprValue.isList() && constExprValue.getList().size() > 1) ||
(constExprValue.isSet() && constExprValue.getSet().size() > 1)) {
return TransformResult::noTransform();
}
} else {
// If the inner IN expr has only 1 element, rewrite it to an relEQ expression and there is
// no need to check whether it has a index
Expand Down

0 comments on commit a2c4241

Please sign in to comment.