From 3c0cce459ee95d64cf38aeb614fe0df87f9ef619 Mon Sep 17 00:00:00 2001 From: "jie.wang" <38901892+jievince@users.noreply.github.com> Date: Wed, 11 Jan 2023 23:43:46 +0800 Subject: [PATCH] fix bug of extract prop expr visitor (#5238) --- src/graph/validator/GoValidator.cpp | 9 +++--- src/graph/validator/GoValidator.h | 2 +- src/graph/visitor/ExtractPropExprVisitor.cpp | 4 --- src/graph/visitor/ExtractPropExprVisitor.h | 2 -- tests/tck/features/go/GO.feature | 31 ++++++++++++++++++++ 5 files changed, 37 insertions(+), 11 deletions(-) diff --git a/src/graph/validator/GoValidator.cpp b/src/graph/validator/GoValidator.cpp index cb2ebf62cd1..065db1ab2f8 100644 --- a/src/graph/validator/GoValidator.cpp +++ b/src/graph/validator/GoValidator.cpp @@ -188,8 +188,8 @@ Status GoValidator::extractTagIds() { return Status::OK(); } -void GoValidator::extractPropExprs(const Expression* expr, - std::unordered_set& uniqueExpr) { +Status GoValidator::extractPropExprs(const Expression* expr, + std::unordered_set& uniqueExpr) { ExtractPropExprVisitor visitor(vctx_, goCtx_->srcEdgePropsExpr, goCtx_->dstPropsExpr, @@ -197,6 +197,7 @@ void GoValidator::extractPropExprs(const Expression* expr, propExprColMap_, uniqueExpr); const_cast(expr)->accept(&visitor); + return std::move(visitor).status(); } Expression* GoValidator::rewriteVertexEdge2EdgeProp(const Expression* expr) { @@ -277,13 +278,13 @@ Status GoValidator::buildColumns() { std::unordered_set uniqueEdgeVertexExpr; auto filter = goCtx_->filter; if (filter != nullptr) { - extractPropExprs(filter, uniqueEdgeVertexExpr); + NG_RETURN_IF_ERROR(extractPropExprs(filter, uniqueEdgeVertexExpr)); goCtx_->filter = rewrite2VarProp(filter); } auto* newYieldExpr = pool->makeAndAdd(); for (auto* col : goCtx_->yieldExpr->columns()) { - extractPropExprs(col->expr(), uniqueEdgeVertexExpr); + NG_RETURN_IF_ERROR(extractPropExprs(col->expr(), uniqueEdgeVertexExpr)); newYieldExpr->addColumn(new YieldColumn(rewrite2VarProp(col->expr()), col->alias())); } diff --git a/src/graph/validator/GoValidator.h b/src/graph/validator/GoValidator.h index 8299c74b569..0f5293f7021 100644 --- a/src/graph/validator/GoValidator.h +++ b/src/graph/validator/GoValidator.h @@ -36,7 +36,7 @@ class GoValidator final : public Validator { Status extractTagIds(); - void extractPropExprs(const Expression* expr, std::unordered_set& uniqueCols); + Status extractPropExprs(const Expression* expr, std::unordered_set& uniqueCols); Expression* rewrite2VarProp(const Expression* expr); diff --git a/src/graph/visitor/ExtractPropExprVisitor.cpp b/src/graph/visitor/ExtractPropExprVisitor.cpp index 61e79c11c61..fa2dd1db8b8 100644 --- a/src/graph/visitor/ExtractPropExprVisitor.cpp +++ b/src/graph/visitor/ExtractPropExprVisitor.cpp @@ -47,10 +47,6 @@ void ExtractPropExprVisitor::visit(VariableExpression* expr) { UNUSED(expr); } -void ExtractPropExprVisitor::visit(SubscriptExpression* expr) { - reportError(expr); -} - void ExtractPropExprVisitor::visit(LabelExpression* expr) { reportError(expr); } diff --git a/src/graph/visitor/ExtractPropExprVisitor.h b/src/graph/visitor/ExtractPropExprVisitor.h index 87095bd8db6..470d403d4d0 100644 --- a/src/graph/visitor/ExtractPropExprVisitor.h +++ b/src/graph/visitor/ExtractPropExprVisitor.h @@ -59,8 +59,6 @@ class ExtractPropExprVisitor final : public ExprVisitorImpl { // vertex/edge expression void visit(VertexExpression *) override; void visit(EdgeExpression *) override; - // binary expression - void visit(SubscriptExpression *) override; // column expression void visit(ColumnExpression *) override; diff --git a/tests/tck/features/go/GO.feature b/tests/tck/features/go/GO.feature index 911d9f4b4cc..9948f3eb869 100644 --- a/tests/tck/features/go/GO.feature +++ b/tests/tck/features/go/GO.feature @@ -576,6 +576,37 @@ Feature: Go Sentence | "Chris Paul" | "Carmelo Anthony" | "Dwyane Wade" | | "Chris Paul" | "Dwyane Wade" | "LeBron James" | | "Chris Paul" | "Dwyane Wade" | "Carmelo Anthony" | + When executing query: + """ + GO 3 STEPS FROM "Tim Duncan" OVER like,serve + WHERE (serve.start_year>2000 OR like.likeness>90) AND size(labels($$)[0]) > 0 AND $$.player.age>40 + yield $$ as v + """ + Then the result should be, in any order, with relax comparison: + | v | + | ("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"}) | + When executing query: + """ + GO 3 STEPS FROM "Tim Duncan" OVER like,serve + WHERE size(labels($$))>0 AND $$.player.age>40 + yield $$ as v + """ + Then the result should be, in any order, with relax comparison: + | v | + | ("Tim Duncan" :bachelor{name: "Tim Duncan", speciality: "psychology"} :player{age: 42, name: "Tim Duncan"}) | + | ("Tim Duncan" :bachelor{name: "Tim Duncan", speciality: "psychology"} :player{age: 42, name: "Tim Duncan"}) | + | ("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"}) | + When executing query: + """ + GO 3 STEPS FROM "Tim Duncan" OVER like,serve + WHERE $$.player.age>40 AND size(labels($$)[0]) > 0 + yield $$ as v + """ + Then the result should be, in any order, with relax comparison: + | v | + | ("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"}) | + | ("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"}) | + | ("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"}) | @skip Scenario: all prop(reason = $-.* over * $var.* not implement)