diff --git a/src/graph/optimizer/rule/PushLimitDownEdgeIndexFullScanRule.cpp b/src/graph/optimizer/rule/PushLimitDownEdgeIndexFullScanRule.cpp index 18822aa7ba5..c6d488da165 100644 --- a/src/graph/optimizer/rule/PushLimitDownEdgeIndexFullScanRule.cpp +++ b/src/graph/optimizer/rule/PushLimitDownEdgeIndexFullScanRule.cpp @@ -41,7 +41,7 @@ StatusOr PushLimitDownEdgeIndexFullScanRule::transform const auto limit = static_cast(limitGroupNode->node()); const auto indexScan = static_cast(indexScanGroupNode->node()); - int64_t limitRows = limit->offset() + limit->count(); + int64_t limitRows = limit->offset() + limit->count(qctx); if (indexScan->limit(qctx) >= 0 && limitRows >= indexScan->limit(qctx)) { return TransformResult::noTransform(); } diff --git a/src/graph/optimizer/rule/PushLimitDownEdgeIndexPrefixScanRule.cpp b/src/graph/optimizer/rule/PushLimitDownEdgeIndexPrefixScanRule.cpp index 6d002e421e0..f34980bc979 100644 --- a/src/graph/optimizer/rule/PushLimitDownEdgeIndexPrefixScanRule.cpp +++ b/src/graph/optimizer/rule/PushLimitDownEdgeIndexPrefixScanRule.cpp @@ -43,7 +43,7 @@ StatusOr PushLimitDownEdgeIndexPrefixScanRule::transfo const auto limit = static_cast(limitGroupNode->node()); const auto indexScan = static_cast(indexScanGroupNode->node()); - int64_t limitRows = limit->offset() + limit->count(); + int64_t limitRows = limit->offset() + limit->count(qctx); if (indexScan->limit(qctx) >= 0 && limitRows >= indexScan->limit(qctx)) { return TransformResult::noTransform(); } diff --git a/src/graph/optimizer/rule/PushLimitDownEdgeIndexRangeScanRule.cpp b/src/graph/optimizer/rule/PushLimitDownEdgeIndexRangeScanRule.cpp index 5d89b0dd9eb..8dd8dc3f2ab 100644 --- a/src/graph/optimizer/rule/PushLimitDownEdgeIndexRangeScanRule.cpp +++ b/src/graph/optimizer/rule/PushLimitDownEdgeIndexRangeScanRule.cpp @@ -41,7 +41,7 @@ StatusOr PushLimitDownEdgeIndexRangeScanRule::transfor const auto limit = static_cast(limitGroupNode->node()); const auto indexScan = static_cast(indexScanGroupNode->node()); - int64_t limitRows = limit->offset() + limit->count(); + int64_t limitRows = limit->offset() + limit->count(qctx); if (indexScan->limit(qctx) >= 0 && limitRows >= indexScan->limit(qctx)) { return TransformResult::noTransform(); } diff --git a/src/graph/optimizer/rule/PushLimitDownGetNeighborsRule.cpp b/src/graph/optimizer/rule/PushLimitDownGetNeighborsRule.cpp index 36db54958e0..069178261b4 100644 --- a/src/graph/optimizer/rule/PushLimitDownGetNeighborsRule.cpp +++ b/src/graph/optimizer/rule/PushLimitDownGetNeighborsRule.cpp @@ -43,7 +43,7 @@ StatusOr PushLimitDownGetNeighborsRule::transform( if (!graph::ExpressionUtils::isEvaluableExpr(limit->countExpr(), octx->qctx())) { return TransformResult::noTransform(); } - int64_t limitRows = limit->offset() + limit->count(); + int64_t limitRows = limit->offset() + limit->count(qctx); if (gn->limit(qctx) >= 0 && limitRows >= gn->limit(qctx)) { return TransformResult::noTransform(); } diff --git a/src/graph/optimizer/rule/PushLimitDownIndexScanRule.cpp b/src/graph/optimizer/rule/PushLimitDownIndexScanRule.cpp index dca21c8840c..089b7d042ed 100644 --- a/src/graph/optimizer/rule/PushLimitDownIndexScanRule.cpp +++ b/src/graph/optimizer/rule/PushLimitDownIndexScanRule.cpp @@ -39,7 +39,7 @@ StatusOr PushLimitDownIndexScanRule::transform( const auto limit = static_cast(limitGroupNode->node()); const auto indexScan = static_cast(indexScanGroupNode->node()); - int64_t limitRows = limit->offset() + limit->count(); + int64_t limitRows = limit->offset() + limit->count(qctx); if (indexScan->limit(qctx) >= 0 && limitRows >= indexScan->limit(qctx)) { return TransformResult::noTransform(); } diff --git a/src/graph/optimizer/rule/PushLimitDownTagIndexFullScanRule.cpp b/src/graph/optimizer/rule/PushLimitDownTagIndexFullScanRule.cpp index fd4879474d1..c48defaaede 100644 --- a/src/graph/optimizer/rule/PushLimitDownTagIndexFullScanRule.cpp +++ b/src/graph/optimizer/rule/PushLimitDownTagIndexFullScanRule.cpp @@ -40,7 +40,7 @@ StatusOr PushLimitDownTagIndexFullScanRule::transform( const auto limit = static_cast(limitGroupNode->node()); const auto indexScan = static_cast(indexScanGroupNode->node()); - int64_t limitRows = limit->offset() + limit->count(); + int64_t limitRows = limit->offset() + limit->count(qctx); if (indexScan->limit(qctx) >= 0 && limitRows >= indexScan->limit(qctx)) { return TransformResult::noTransform(); } diff --git a/src/graph/optimizer/rule/PushLimitDownTagIndexPrefixScanRule.cpp b/src/graph/optimizer/rule/PushLimitDownTagIndexPrefixScanRule.cpp index 11a76d5796f..905492d3632 100644 --- a/src/graph/optimizer/rule/PushLimitDownTagIndexPrefixScanRule.cpp +++ b/src/graph/optimizer/rule/PushLimitDownTagIndexPrefixScanRule.cpp @@ -40,7 +40,7 @@ StatusOr PushLimitDownTagIndexPrefixScanRule::transfor const auto limit = static_cast(limitGroupNode->node()); const auto indexScan = static_cast(indexScanGroupNode->node()); - int64_t limitRows = limit->offset() + limit->count(); + int64_t limitRows = limit->offset() + limit->count(qctx); if (indexScan->limit(qctx) >= 0 && limitRows >= indexScan->limit(qctx)) { return TransformResult::noTransform(); } diff --git a/src/graph/optimizer/rule/PushLimitDownTagIndexRangeScanRule.cpp b/src/graph/optimizer/rule/PushLimitDownTagIndexRangeScanRule.cpp index 74a431ed640..7642108f715 100644 --- a/src/graph/optimizer/rule/PushLimitDownTagIndexRangeScanRule.cpp +++ b/src/graph/optimizer/rule/PushLimitDownTagIndexRangeScanRule.cpp @@ -40,7 +40,7 @@ StatusOr PushLimitDownTagIndexRangeScanRule::transform const auto limit = static_cast(limitGroupNode->node()); const auto indexScan = static_cast(indexScanGroupNode->node()); - int64_t limitRows = limit->offset() + limit->count(); + int64_t limitRows = limit->offset() + limit->count(qctx); if (indexScan->limit(qctx) >= 0 && limitRows >= indexScan->limit(qctx)) { return TransformResult::noTransform(); } diff --git a/src/graph/optimizer/rule/PushStepLimitDownGetNeighborsRule.cpp b/src/graph/optimizer/rule/PushStepLimitDownGetNeighborsRule.cpp index 7f2816ccf91..60b13f52657 100644 --- a/src/graph/optimizer/rule/PushStepLimitDownGetNeighborsRule.cpp +++ b/src/graph/optimizer/rule/PushStepLimitDownGetNeighborsRule.cpp @@ -42,7 +42,7 @@ StatusOr PushStepLimitDownGetNeighborsRule::transform( if (gn->limitExpr() != nullptr && graph::ExpressionUtils::isEvaluableExpr(gn->limitExpr(), qctx) && graph::ExpressionUtils::isEvaluableExpr(limit->countExpr(), qctx)) { - int64_t limitRows = limit->offset() + limit->count(); + int64_t limitRows = limit->offset() + limit->count(qctx); int64_t gnLimit = gn->limit(qctx); if (gnLimit >= 0 && limitRows >= gnLimit) { return TransformResult::noTransform(); diff --git a/src/graph/optimizer/rule/TopNRule.cpp b/src/graph/optimizer/rule/TopNRule.cpp index 17171fc4872..a9a29176a7b 100644 --- a/src/graph/optimizer/rule/TopNRule.cpp +++ b/src/graph/optimizer/rule/TopNRule.cpp @@ -43,7 +43,7 @@ StatusOr TopNRule::transform(OptContext *ctx, } auto qctx = ctx->qctx(); - auto topn = TopN::make(qctx, nullptr, sort->factors(), limit->offset(), limit->count()); + auto topn = TopN::make(qctx, nullptr, sort->factors(), limit->offset(), limit->count(qctx)); topn->setOutputVar(limit->outputVar()); topn->setInputVar(sort->inputVar()); topn->setColNames(sort->colNames()); diff --git a/src/graph/planner/plan/Query.h b/src/graph/planner/plan/Query.h index eb41a4b8d84..4db8f526012 100644 --- a/src/graph/planner/plan/Query.h +++ b/src/graph/planner/plan/Query.h @@ -681,13 +681,12 @@ class Limit final : public SingleInputNode { int64_t offset() const { return offset_; } // Get constant count value - int64_t count() const { + int64_t count(QueryContext* qctx) const { if (count_ == nullptr) { return -1; } - DCHECK(ExpressionUtils::isEvaluableExpr(count_)); - QueryExpressionContext ctx; - auto s = count_->eval(ctx).getInt(); + DCHECK(ExpressionUtils::isEvaluableExpr(count_, qctx)); + auto s = count_->eval(QueryExpressionContext(qctx->ectx())()).getInt(); DCHECK_GE(s, 0); return s; }