From a2c424159cddda495f38c9f69ab98a869170690d Mon Sep 17 00:00:00 2001 From: "kyle.cao" Date: Fri, 18 Nov 2022 18:25:31 +0800 Subject: [PATCH] fix lookup index selection --- .../rule/OptimizeTagIndexScanByFilterRule.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/graph/optimizer/rule/OptimizeTagIndexScanByFilterRule.cpp b/src/graph/optimizer/rule/OptimizeTagIndexScanByFilterRule.cpp index c87790e2089..fec268b1eed 100644 --- a/src/graph/optimizer/rule/OptimizeTagIndexScanByFilterRule.cpp +++ b/src/graph/optimizer/rule/OptimizeTagIndexScanByFilterRule.cpp @@ -135,8 +135,16 @@ StatusOr OptimizeTagIndexScanByFilterRule::transform( auto inExpr = static_cast(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(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(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