Skip to content

Commit

Permalink
Merge branch 'master' into fix-fulltext-index
Browse files Browse the repository at this point in the history
  • Loading branch information
Sophie-Xie authored Jan 11, 2023
2 parents 5816fb1 + 3c0cce4 commit c22701a
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 11 deletions.
9 changes: 5 additions & 4 deletions src/graph/validator/GoValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,16 @@ Status GoValidator::extractTagIds() {
return Status::OK();
}

void GoValidator::extractPropExprs(const Expression* expr,
std::unordered_set<std::string>& uniqueExpr) {
Status GoValidator::extractPropExprs(const Expression* expr,
std::unordered_set<std::string>& uniqueExpr) {
ExtractPropExprVisitor visitor(vctx_,
goCtx_->srcEdgePropsExpr,
goCtx_->dstPropsExpr,
inputPropCols_,
propExprColMap_,
uniqueExpr);
const_cast<Expression*>(expr)->accept(&visitor);
return std::move(visitor).status();
}

Expression* GoValidator::rewriteVertexEdge2EdgeProp(const Expression* expr) {
Expand Down Expand Up @@ -277,13 +278,13 @@ Status GoValidator::buildColumns() {
std::unordered_set<std::string> 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<YieldColumns>();
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()));
}

Expand Down
2 changes: 1 addition & 1 deletion src/graph/validator/GoValidator.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class GoValidator final : public Validator {

Status extractTagIds();

void extractPropExprs(const Expression* expr, std::unordered_set<std::string>& uniqueCols);
Status extractPropExprs(const Expression* expr, std::unordered_set<std::string>& uniqueCols);

Expression* rewrite2VarProp(const Expression* expr);

Expand Down
4 changes: 0 additions & 4 deletions src/graph/visitor/ExtractPropExprVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 0 additions & 2 deletions src/graph/visitor/ExtractPropExprVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
31 changes: 31 additions & 0 deletions tests/tck/features/go/GO.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c22701a

Please sign in to comment.