From a0e8493195e5015d4b416a0ad5f243913cd6851c Mon Sep 17 00:00:00 2001 From: "kyle.cao" Date: Tue, 18 Apr 2023 14:09:02 +0800 Subject: [PATCH] Fix regex expression (#5507) --- src/common/expression/RelationalExpression.cpp | 3 ++- .../features/expression/RelationalExpr.feature | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/common/expression/RelationalExpression.cpp b/src/common/expression/RelationalExpression.cpp index 645dbf4272d..70342658130 100644 --- a/src/common/expression/RelationalExpression.cpp +++ b/src/common/expression/RelationalExpression.cpp @@ -37,7 +37,8 @@ const Value& RelationalExpression::eval(ExpressionContext& ctx) { case Kind::kRelREG: { if (lhs.isBadNull() || rhs.isBadNull()) { result_ = Value::kNullBadType; - } else if ((!lhs.isNull() && !lhs.isStr()) || (!rhs.isNull() && !rhs.isStr())) { + } else if ((!lhs.isNull() && !lhs.empty() && !lhs.isStr()) || + (!rhs.isNull() && !rhs.empty() && !rhs.isStr())) { result_ = Value::kNullBadType; } else if (lhs.isStr() && rhs.isStr()) { try { diff --git a/tests/tck/features/expression/RelationalExpr.feature b/tests/tck/features/expression/RelationalExpr.feature index 16662f0b5b8..bcf77a3a125 100644 --- a/tests/tck/features/expression/RelationalExpr.feature +++ b/tests/tck/features/expression/RelationalExpr.feature @@ -233,3 +233,21 @@ Feature: RelationalExpression | 2 | AppendVertices | 6 | | | 6 | IndexScan | 0 | {"indexCtx": {"columnHints":{"scanType":"RANGE"}}} | | 0 | Start | | | + + Scenario: Transform Relational expr in MATCH clause + When profiling query: + """ + MATCH (v:player{name: "Tim Duncan"})-[e]->(m) WHERE m.player.name =~ 'Tony.*' RETURN id(m) AS id + """ + Then the result should be, in any order: + | id | + | "Tony Parker" | + | "Tony Parker" | + And the execution plan should be: + | id | name | dependencies | operator info | + | 13 | Project | 12 | | + | 12 | Filter | 12 | | + | 12 | AppendVertices | 11 | | + | 11 | Traverse | 8 | | + | 8 | IndexScan | 0 | | + | 0 | Start | | |