From fdcaa0a9d9831a852c784b93b6a12746e0a7c591 Mon Sep 17 00:00:00 2001 From: shylock <33566796+Shylock-Hg@users.noreply.github.com> Date: Mon, 21 Feb 2022 17:55:19 +0800 Subject: [PATCH] Fix crash of null path expression. (#3915) * Fix crash of null path expression. * Add test case. Co-authored-by: jakevin <30525741+jackwener@users.noreply.github.com> --- src/graph/planner/match/MatchClausePlanner.cpp | 2 +- .../bugfix/CrashWhenNullPathExpr.feature | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/tck/features/bugfix/CrashWhenNullPathExpr.feature diff --git a/src/graph/planner/match/MatchClausePlanner.cpp b/src/graph/planner/match/MatchClausePlanner.cpp index 3bbc1985593..ed998b79512 100644 --- a/src/graph/planner/match/MatchClausePlanner.cpp +++ b/src/graph/planner/match/MatchClausePlanner.cpp @@ -409,7 +409,7 @@ Status MatchClausePlanner::projectColumnsBySymbols(MatchClauseContext* matchClau auto iter = std::find_if(aliases.begin(), aliases.end(), [](const auto& alias) { return alias.second == AliasType::kPath; }); - if (iter != aliases.end()) { + if (iter != aliases.end() && path.pathBuild != nullptr) { auto& alias = iter->first; columns->addColumn(buildPathColumn(path.pathBuild, alias)); colNames.emplace_back(alias); diff --git a/tests/tck/features/bugfix/CrashWhenNullPathExpr.feature b/tests/tck/features/bugfix/CrashWhenNullPathExpr.feature new file mode 100644 index 00000000000..ed5392bf9e3 --- /dev/null +++ b/tests/tck/features/bugfix/CrashWhenNullPathExpr.feature @@ -0,0 +1,17 @@ +# Copyright (c) 2022 vesoft inc. All rights reserved. +# +# This source code is licensed under Apache 2.0 License. +Feature: Test crash when null path expression + + Background: + Given a graph with space named "nba" + + Scenario: Null path expression in multiple patterns + When executing query: + """ + MATCH (p:player {name: 'Yao Ming'} ), (t:team {name: 'Rockets'}), pth = (p)-[:serve*1..4]-(t) + RETURN pth + """ + Then the result should be, in any order, with relax comparison: + | pth | + | <("Yao Ming":player{age:38,name:"Yao Ming"})-[:serve@0{end_year:2011,start_year:2002}]->("Rockets":team{name:"Rockets"})> |