Skip to content

Commit b5df04f

Browse files
Fix wrong properties prune in length function. (#4884)
Co-authored-by: Sophie <84560950+Sophie-Xie@users.noreply.github.com>
1 parent ae7e2fe commit b5df04f

File tree

3 files changed

+43
-23
lines changed

3 files changed

+43
-23
lines changed

src/graph/visitor/PropertyTrackerVisitor.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,10 @@ void PropertyTrackerVisitor::visit(AttributeExpression *expr) {
279279
}
280280

281281
void PropertyTrackerVisitor::visit(FunctionCallExpression *expr) {
282+
// length function support `STRING` input too, so we can't ignore it directly
283+
// TODO add type info to variable to help optimize it.
282284
static const std::unordered_set<std::string> ignoreFuncs = {
283-
"src", "dst", "type", "typeid", "id", "rank", "length"};
285+
"src", "dst", "type", "typeid", "id", "rank" /*, "length"*/};
284286

285287
auto funName = expr->name();
286288
std::transform(funName.begin(), funName.end(), funName.begin(), ::tolower);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright (c) 2022 vesoft inc. All rights reserved.
2+
#
3+
# This source code is licensed under Apache 2.0 License.
4+
Feature: Null input of length function
5+
6+
Background:
7+
Given a graph with space named "nba"
8+
9+
Scenario: Null input of length function
10+
When executing query:
11+
"""
12+
match p = (v)-[:like]->() where id(v) == 'Tim Duncan'
13+
return length(v.player.name) as l, length(p) as lp
14+
"""
15+
Then the result should be, in any order:
16+
| l | lp |
17+
| 10 | 1 |
18+
| 10 | 1 |

tests/tck/features/optimizer/PrunePropertiesRule.feature

+22-22
Original file line numberDiff line numberDiff line change
@@ -439,14 +439,14 @@ Feature: Prune Properties rule
439439
| length(p) |
440440
| 1 |
441441
And the execution plan should be:
442-
| id | name | dependencies | operator info |
443-
| 13 | Project | 11 | |
444-
| 11 | Limit | 5 | |
445-
| 5 | AppendVertices | 4 | { "props": "[{\"props\":[\"_tag\"],\"tagId\":8}, {\"props\":[\"_tag\"],\"tagId\":9}, {\"props\":[\"_tag\"],\"tagId\":10}]" } |
446-
| 4 | Traverse | 2 | {"vertexProps": "", "edgeProps": "[{\"type\": 3, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } |
447-
| 2 | Dedup | 1 | |
448-
| 1 | PassThrough | 3 | |
449-
| 3 | Start | | |
442+
| id | name | dependencies | operator info |
443+
| 13 | Project | 11 | |
444+
| 11 | Limit | 5 | |
445+
| 5 | AppendVertices | 4 | { "props": "[{\"props\":[\"_tag\", \"name\", \"speciality\"],\"tagId\":8}, {\"props\":[\"_tag\", \"name\", \"age\"],\"tagId\":9}, {\"props\":[\"_tag\", \"name\"],\"tagId\":10}]" } |
446+
| 4 | Traverse | 2 | {"vertexProps": "[{\"props\":[\"name\", \"age\", \"_tag\"],\"tagId\":9}, {\"props\":[\"name\", \"speciality\", \"_tag\"],\"tagId\":8}, {\"props\":[\"name\", \"_tag\"],\"tagId\":10}]", "edgeProps": "[{\"type\": 3, \"props\": [\"_type\", \"_rank\", \"_dst\", \"_src\", \"likeness\"]}]" } |
447+
| 2 | Dedup | 1 | |
448+
| 1 | PassThrough | 3 | |
449+
| 3 | Start | | |
450450
When profiling query:
451451
"""
452452
MATCH p = (a:player)-[e:like*1..3]->(b:player{age:39})
@@ -466,20 +466,20 @@ Feature: Prune Properties rule
466466
| "Tracy McGrady" | 1 |
467467
| "Tracy McGrady" | 3 |
468468
And the execution plan should be:
469-
| id | name | dependencies | operator info |
470-
| 14 | Project | 13 | |
471-
| 13 | BiInnerJoin | 15,12 | |
472-
| 15 | Project | 17 | |
473-
| 17 | AppendVertices | 16 | { "props": "[{\"props\":[\"name\",\"age\"],\"tagId\":9}]" } |
474-
| 16 | Traverse | 2 | {"vertexProps": "", "edgeProps": "[{\"type\": 3, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } |
475-
| 2 | Dedup | 1 | |
476-
| 1 | PassThrough | 3 | |
477-
| 3 | Start | | |
478-
| 12 | Project | 18 | |
479-
| 18 | AppendVertices | 10 | { "props": "[{\"props\":[\"_tag\"],\"tagId\":10}]" } |
480-
| 10 | Traverse | 8 | {"vertexProps": "[{\"props\":[\"name\",\"age\"],\"tagId\":9}]", "edgeProps": "[{\"type\": 4, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } |
481-
| 8 | Argument | | |
482-
| 9 | Start | | |
469+
| id | name | dependencies | operator info |
470+
| 14 | Project | 13 | |
471+
| 13 | BiInnerJoin | 15,12 | |
472+
| 15 | Project | 17 | |
473+
| 17 | AppendVertices | 16 | { "props": "[{\"props\":[\"_tag\", \"name\", \"speciality\"],\"tagId\":8}, {\"props\":[\"_tag\", \"name\", \"age\"],\"tagId\":9}, {\"props\":[\"_tag\", \"name\"],\"tagId\":10}]" } |
474+
| 16 | Traverse | 2 | {"vertexProps": "[{\"props\":[\"name\", \"age\", \"_tag\"],\"tagId\":9}, {\"props\":[\"name\", \"speciality\", \"_tag\"],\"tagId\":8}, {\"props\":[\"name\", \"_tag\"],\"tagId\":10}]", "edgeProps": "[{\"type\": 3, \"props\": [\"_type\", \"_rank\", \"_dst\", \"_src\", \"likeness\"]}]" } |
475+
| 2 | Dedup | 1 | |
476+
| 1 | PassThrough | 3 | |
477+
| 3 | Start | | |
478+
| 12 | Project | 18 | |
479+
| 18 | AppendVertices | 10 | { "props": "[{\"props\":[\"_tag\"],\"tagId\":10}]" } |
480+
| 10 | Traverse | 8 | {"vertexProps": "[{\"props\":[\"name\", \"age\", \"_tag\"],\"tagId\":9}, {\"props\":[\"name\", \"speciality\", \"_tag\"],\"tagId\":8}, {\"props\":[\"name\", \"_tag\"],\"tagId\":10}]", "edgeProps": "[{\"type\": 4, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } |
481+
| 8 | Argument | | |
482+
| 9 | Start | | |
483483

484484
@distonly
485485
Scenario: union match

0 commit comments

Comments
 (0)