Skip to content

Commit

Permalink
fix IndexScan with label containing parameters (#5944)
Browse files Browse the repository at this point in the history
* fix IndexScan with label containing parameters

* chore: improve formatting in VariableExpression.h

* Enable the TCK tests that were previously skipped due to bugs.
  • Loading branch information
Xscaperrr authored Nov 18, 2024
1 parent 6c59b79 commit 6e0f646
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/common/expression/VariableExpression.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class VariableExpression final : public Expression {
return isInner_;
}

void setInner(bool inner) {
isInner_ = inner;
}

const Value& eval(ExpressionContext& ctx) override;

bool operator==(const Expression& rhs) const override {
Expand Down
4 changes: 3 additions & 1 deletion src/graph/util/ExpressionUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ Expression *ExpressionUtils::rewriteParameter(const Expression *expr, QueryConte
};
auto rewriter = [qctx](const Expression *e) -> Expression * {
DCHECK_EQ(e->kind(), Expression::Kind::kVar);
auto &v = const_cast<Expression *>(e)->eval(graph::QueryExpressionContext(qctx->ectx())());
auto exp = static_cast<VariableExpression *>(const_cast<Expression *>(e));
exp->setInner(false);
auto &v = exp->eval(graph::QueryExpressionContext(qctx->ectx())());
return ConstantExpression::make(qctx->objPool(), v);
};

Expand Down
21 changes: 21 additions & 0 deletions tests/tck/features/bugfix/ParameterQuery.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Feature: Test excute index scan with label which contains parameters

Background:
Given an empty graph
And load "nba" csv data to a new space
Given parameters: {"p1":"Tim Duncan"}

Scenario: execute index scan with label which contains parameters
When profiling query:
"""
MATCH (v:player{name:$p1}) RETURN v.player.age
"""
Then the result should be, in any order:
| v.player.age |
| 42 |
Then the execution plan should be:
| id | name | dependencies | operator info |
| 4 | Project | 3 | |
| 3 | AppendVertices | 2 | |
| 2 | IndexScan | 1 | {"indexCtx": {"columnHints":{"scanType":"PREFIX"}}} |
| 1 | Start | | |
1 change: 0 additions & 1 deletion tests/tck/features/match/Path.feature
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ Feature: Matching paths
| count(p) | count(p2) |
| 94 | 94 |

@skip #bug to fix: https://github.com/vesoft-inc/nebula/issues/5187
Scenario: edge directions in paths
When executing query:
"""
Expand Down
1 change: 0 additions & 1 deletion tests/tck/features/yield/parameter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ Feature: Parameter
| v |
| {a: 3, b: false, c: "Tim Duncan"} |

@skip #bug to fix: https://github.com/vesoft-inc/nebula/issues/5939
Scenario: [param-test-004] cypher with parameters
# where clause
When executing query:
Expand Down

0 comments on commit 6e0f646

Please sign in to comment.