Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert strange return #5183

Merged
merged 2 commits into from
Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/parser/parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -1644,6 +1644,14 @@ yield_sentence
s->setWhereClause($4);
$$ = s;
}
| KW_RETURN yield_columns {
auto *s = new YieldSentence($2);
$$ = s;
}
| KW_RETURN KW_DISTINCT yield_columns {
auto *s = new YieldSentence($3, true);
$$ = s;
}
;

unwind_clause
Expand Down Expand Up @@ -1720,10 +1728,7 @@ reading_with_clauses
;

match_sentence
: match_return {
$$ = new MatchSentence(new MatchClauseList(), $1);
}
| reading_clauses match_return {
: reading_clauses match_return {
$$ = new MatchSentence($1, $2);
}
| reading_with_clauses match_return {
Expand Down
22 changes: 17 additions & 5 deletions tests/tck/features/set/Set.feature
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,21 @@ Feature: Set Test
| a |
| 1 |
| 2 |
# cypher doesn't support intersect
# The standalone return statement is not a cypher statement but a ngql statement in nebula...
# So it can't be mixed with other cypher statements
When executing query:
"""
UNWIND [1,2] AS a RETURN a
INTERSECT
RETURN 2 AS a
RETURN a
"""
Then a SyntaxError should be raised at runtime:
When executing query:
"""
UNWIND [1,2] AS a RETURN a
INTERSECT
WITH 2 AS a
RETURN a
"""
Then the result should be, in any order:
| a |
Expand All @@ -89,7 +98,8 @@ Feature: Set Test
"""
UNWIND [1,2,3] AS a RETURN a, 100
INTERSECT
RETURN 2 AS a, 100
WITH 2 AS a
RETURN a, 100
"""
Then the result should be, in any order:
| a | 100 |
Expand Down Expand Up @@ -291,7 +301,8 @@ Feature: Set Test
"""
UNWIND [1,2,3] AS a RETURN a
MINUS
RETURN 4 AS a
WITH 4 AS a
RETURN a
"""
Then the result should be, in any order, with relax comparison:
| a |
Expand All @@ -302,7 +313,8 @@ Feature: Set Test
"""
UNWIND [1,2,3] AS a RETURN a
MINUS
RETURN 2 AS a
WITH 2 AS a
RETURN a
"""
Then the result should be, in any order, with relax comparison:
| a |
Expand Down
20 changes: 18 additions & 2 deletions tests/tck/features/yield/return.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) 2020 vesoft inc. All rights reserved.
#
# This source code is licensed under Apache 2.0 License.
Feature: Return
Feature: Return. A standalone return sentence is actually a yield sentence

Background:
Given a graph with space named "nba"
Expand All @@ -21,6 +21,22 @@ Feature: Return
Then the result should be, in any order:
| (1+1) | "1+1" | (INT)3.14 | (STRING)(1+1) | (STRING)true |
| 2 | "1+1" | 3 | "2" | "true" |
When executing query:
"""
GO FROM "Tony Parker" OVER like YIELD id($$) AS vid | RETURN $-.vid AS dst
"""
Then the result should be, in any order, with relax comparison:
| dst |
| "LaMarcus Aldridge" |
| "Manu Ginobili" |
| "Tim Duncan" |
When executing query:
"""
FETCH PROP ON player "Tony Parker" YIELD player.age as age | RETURN $-.age + 100 AS age
"""
Then the result should be, in any order, with relax comparison:
| age |
| 136 |

Scenario: hash call
When executing query:
Expand Down Expand Up @@ -79,4 +95,4 @@ Feature: Return
"""
RETURN name
"""
Then a SemanticError should be raised at runtime: Alias used but not defined: `name'
Then a SemanticError should be raised at runtime: Invalid label identifiers: name