Skip to content

Commit beef5ba

Browse files
committed
support intersect/minus for cypher
1 parent 7a7470a commit beef5ba

8 files changed

Lines changed: 20 additions & 10 deletions

File tree

src/common/expression/test/TestBase.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class ExpressionTest : public ::testing::Test {
6060

6161
protected:
6262
void testExpr(const std::string &exprSymbol, Value expected) {
63-
std::string query = "RETURN " + exprSymbol;
63+
std::string query = "YIELD " + exprSymbol;
6464
nebula::graph::QueryContext queryCtxt;
6565
nebula::GQLParser gParser(&queryCtxt);
6666
auto result = gParser.parse(query);
@@ -86,7 +86,7 @@ class ExpressionTest : public ::testing::Test {
8686
}
8787

8888
void testToString(const std::string &exprSymbol, const char *expected) {
89-
std::string query = "RETURN " + exprSymbol;
89+
std::string query = "YIELD " + exprSymbol;
9090
nebula::graph::QueryContext queryCtxt;
9191
nebula::GQLParser gParser(&queryCtxt);
9292
auto result = gParser.parse(query);
@@ -106,7 +106,7 @@ class ExpressionTest : public ::testing::Test {
106106
}
107107

108108
void testFunction(const char *name, const std::vector<Value> &args, const Value &expected) {
109-
std::string query = "RETURN " + std::string(name) + "(";
109+
std::string query = "YIELD " + std::string(name) + "(";
110110
for (const auto &i : args) {
111111
query += i.toString() + ",";
112112
}

src/graph/context/ast/CypherAstContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ struct YieldClauseContext final : CypherClauseContextBase {
158158
std::vector<Path> paths;
159159

160160
bool distinct{false};
161-
const YieldColumns* yieldColumns{nullptr};
161+
YieldColumns* yieldColumns{nullptr};
162162

163163
bool hasAgg_{false};
164164
bool needGenProject_{false};

src/graph/validator/MatchValidator.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,13 +1063,17 @@ Status MatchValidator::checkAlias(
10631063

10641064
// Validate yield columns.
10651065
// Fill outputs of whole sentence.
1066-
Status MatchValidator::buildOutputs(const YieldColumns *yields) {
1066+
Status MatchValidator::buildOutputs(YieldColumns *yields) {
10671067
for (auto *col : yields->columns()) {
10681068
auto colName = col->name();
10691069
auto typeStatus = deduceExprType(col->expr());
10701070
NG_RETURN_IF_ERROR(typeStatus);
10711071
auto type = typeStatus.value();
10721072
outputs_.emplace_back(colName, type);
1073+
1074+
auto foldStatus = ExpressionUtils::foldConstantExpr(col->expr());
1075+
NG_RETURN_IF_ERROR(foldStatus);
1076+
col->setExpr(foldStatus.value());
10731077
}
10741078
return Status::OK();
10751079
}

src/graph/validator/MatchValidator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class MatchValidator final : public Validator {
8787
Status checkAlias(const Expression *refExpr,
8888
const std::unordered_map<std::string, AliasType> &aliasesAvailable) const;
8989

90-
Status buildOutputs(const YieldColumns *yields);
90+
Status buildOutputs(YieldColumns *yields);
9191

9292
StatusOr<Expression *> makeEdgeSubFilter(MapExpression *map) const;
9393

tests/tck/features/expression/Case.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ Feature: Case Expression
298298
Scenario: Using the return value of case expr as an input
299299
When executing query:
300300
"""
301-
RETURN CASE WHEN true THEN "Tim Duncan" ELSE "ABC" END AS a | GO FROM $-.a OVER like YIELD like._dst;
301+
YIELD CASE WHEN true THEN "Tim Duncan" ELSE "ABC" END AS a | GO FROM $-.a OVER like YIELD like._dst;
302302
"""
303303
Then the result should be, in order:
304304
| like._dst |

tests/tck/features/expression/function/Mathematical.feature

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
# This source code is licensed under Apache 2.0 License.
44
Feature: Mathematical function Expression
55

6+
Background:
7+
Given a graph with space named "nba"
8+
69
Scenario: bit functions
710
When executing query:
811
"""

tests/tck/features/function/coalesce.feature

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
# Copyright (c) 2022 vesoft inc. All rights reserved.
2+
#
3+
# This source code is licensed under Apache 2.0 License.
14
Feature: Coalesce Function
25

36
Background:
4-
Test coalesce function
7+
Given a graph with space named "nba"
58

69
Scenario: test normal case
710
When executing query:

tests/tck/features/yield/return.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Feature: Return
55

66
Background:
7-
Given an empty graph
7+
Given a graph with space named "nba"
88

99
Scenario: base
1010
When executing query:
@@ -79,4 +79,4 @@ Feature: Return
7979
"""
8080
RETURN name
8181
"""
82-
Then a SemanticError should be raised at runtime: Invalid label identifiers: name
82+
Then a SemanticError should be raised at runtime: Alias used but not defined: `name'

0 commit comments

Comments
 (0)