Skip to content

Commit

Permalink
Fix/null pattern expression input (#4180)
Browse files Browse the repository at this point in the history
* Move input rows of Traverse and AppendVertices.

* Avoid skip validate pattern expression with aggregate.

* Fix case.

* Revert "Move input rows of Traverse and AppendVertices."

This reverts commit 7fd1d38.

Co-authored-by: Sophie <[email protected]>
  • Loading branch information
Shylock-Hg and Sophie-Xie authored Apr 20, 2022
1 parent 9c6236d commit 607330d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/graph/validator/MatchValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,7 @@ Status MatchValidator::validateGroup(YieldClauseContext &yieldCtx,
DCHECK(!cols.empty());
for (auto *col : cols) {
auto *colExpr = col->expr();
NG_RETURN_IF_ERROR(validateMatchPathExpr(colExpr, yieldCtx.aliasesAvailable, matchs));
auto colOldName = col->name();
if (colExpr->kind() != Expression::Kind::kAggregate) {
auto collectAggCol = colExpr->clone();
Expand Down Expand Up @@ -834,8 +835,6 @@ Status MatchValidator::validateGroup(YieldClauseContext &yieldCtx,
yieldCtx.groupKeys_.emplace_back(colExpr);
}

NG_RETURN_IF_ERROR(validateMatchPathExpr(colExpr, yieldCtx.aliasesAvailable, matchs));

yieldCtx.groupItems_.emplace_back(colExpr);

yieldCtx.projCols_->addColumn(
Expand Down
18 changes: 18 additions & 0 deletions tests/tck/features/bugfix/AggPatternExpression.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (c) 2022 vesoft inc. All rights reserved.
#
# This source code is licensed under Apache 2.0 License.
# #4175
Feature: Test crash when aggregate with pattern expression

Background:
Given a graph with space named "nba"

Scenario: Crash when aggregate with pattern expression
# TODO aggregate should bypass all input, like `(v)--(:team)` here
When executing query:
"""
MATCH (v:player) WHERE id(v) == 'Tim Duncan' return v.player.name AS name, size((v)--(:team)) + count(v.player.name) * 2 AS count
"""
Then the result should be, in any order, with relax comparison:
| name | count |
| 'Tim Duncan' | NULL |

0 comments on commit 607330d

Please sign in to comment.