Skip to content

Commit

Permalink
Fix regex expression (#5507)
Browse files Browse the repository at this point in the history
  • Loading branch information
czpmango authored and Sophie-Xie committed Apr 19, 2023
1 parent 1ecbdba commit a0e8493
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/common/expression/RelationalExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
18 changes: 18 additions & 0 deletions tests/tck/features/expression/RelationalExpr.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 | | |

0 comments on commit a0e8493

Please sign in to comment.