diff --git a/src/parser/parser.yy b/src/parser/parser.yy index f3d9847fef9..27042a80db4 100644 --- a/src/parser/parser.yy +++ b/src/parser/parser.yy @@ -1696,11 +1696,21 @@ yield_sentence $$ = s; } | KW_YIELD yield_columns join_clause { + if ($2->hasAgg()) { + delete($2); + delete($3); + throw nebula::GraphParser::syntax_error(@2, "Invalid use of aggregating function in yield clause."); + } auto *s = new YieldSentence($2); s->setJoinClause($3); $$ = s; } | KW_YIELD KW_DISTINCT yield_columns join_clause { + if ($3->hasAgg()) { + delete($3); + delete($4); + throw nebula::GraphParser::syntax_error(@2, "Invalid use of aggregating function in yield clause."); + } auto *s = new YieldSentence($3, true); s->setJoinClause($4); $$ = s; diff --git a/tests/tck/features/yield/join.feature b/tests/tck/features/yield/join.feature index d5be0b67053..787447adc94 100644 --- a/tests/tck/features/yield/join.feature +++ b/tests/tck/features/yield/join.feature @@ -7,6 +7,13 @@ Feature: join Given a graph with space named "nba" Scenario: invalid join + When executing query: + """ + $a = GO FROM 'Tim Duncan' OVER like YIELD id($$) as vid, edge as e; + $b = GO FROM 'Tony Parker' OVER like YIELD id($$) as vid, edge as e; + YIELD $a.vid AS id, $b.e AS e, count(*) FROM $a INNER JOIN $b ON $a.vid == $b.vid + """ + Then a SyntaxError should be raised at runtime: Invalid use of aggregating function in yield clause. near `$a.vid AS id, $b.e AS e, count(*)' When executing query: """ $a = GO FROM 'Tim Duncan' OVER like YIELD id($$) as vid, edge as e; @@ -359,3 +366,17 @@ Feature: join | [:like "Marco Belinelli"->"Tim Duncan" @0 {likeness: 55}] | [:like "Tony Parker"->"Tim Duncan" @0 {likeness: 95}] | | [:like "Marco Belinelli"->"Tim Duncan" @0 {likeness: 55}] | [:like "Tony Parker"->"Tim Duncan" @0 {likeness: 95}] | | [:like "Marco Belinelli"->"Tim Duncan" @0 {likeness: 55}] | [:like "Tony Parker"->"Tim Duncan" @0 {likeness: 95}] | + + Scenario: join limit + When executing query: + """ + $a = GO FROM "Tim Duncan" OVER like YIELD src(edge) AS src, edge AS e1; + $b = GO 2 STEPS FROM "Tony Parker" OVER like YIELD edge AS e2, dst(edge) AS dst; + YIELD $a.e1 AS e1, $b.e2 AS e2 from $a inner join $b ON $a.src == $b.dst | limit 10 + """ + Then the result should be, in any order, with relax comparison: + | e1 | e2 | + | [:like "Tim Duncan"->"Manu Ginobili" @0 {likeness: 95}] | [:like "LaMarcus Aldridge"->"Tim Duncan" @0 {likeness: 75}] | + | [:like "Tim Duncan"->"Tony Parker" @0 {likeness: 95}] | [:like "LaMarcus Aldridge"->"Tim Duncan" @0 {likeness: 75}] | + | [:like "Tim Duncan"->"Manu Ginobili" @0 {likeness: 95}] | [:like "Manu Ginobili"->"Tim Duncan" @0 {likeness: 90}] | + | [:like "Tim Duncan"->"Tony Parker" @0 {likeness: 95}] | [:like "Manu Ginobili"->"Tim Duncan" @0 {likeness: 90}] |