From 607330d61ec69e4d57457c345461b98ae22ed54f Mon Sep 17 00:00:00 2001 From: shylock <33566796+Shylock-Hg@users.noreply.github.com> Date: Wed, 20 Apr 2022 08:47:40 +0800 Subject: [PATCH] Fix/null pattern expression input (#4180) * 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 7fd1d3844268063d8a6758e473bef35765fc6832. Co-authored-by: Sophie <84560950+Sophie-Xie@users.noreply.github.com> --- src/graph/validator/MatchValidator.cpp | 3 +-- .../bugfix/AggPatternExpression.feature | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 tests/tck/features/bugfix/AggPatternExpression.feature diff --git a/src/graph/validator/MatchValidator.cpp b/src/graph/validator/MatchValidator.cpp index 93cc0fc6be9..1e42f0849cf 100644 --- a/src/graph/validator/MatchValidator.cpp +++ b/src/graph/validator/MatchValidator.cpp @@ -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(); @@ -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( diff --git a/tests/tck/features/bugfix/AggPatternExpression.feature b/tests/tck/features/bugfix/AggPatternExpression.feature new file mode 100644 index 00000000000..31b83f860d9 --- /dev/null +++ b/tests/tck/features/bugfix/AggPatternExpression.feature @@ -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 |