diff --git a/src/graph/visitor/PropertyTrackerVisitor.cpp b/src/graph/visitor/PropertyTrackerVisitor.cpp index ce3042c717a..0456876ba52 100644 --- a/src/graph/visitor/PropertyTrackerVisitor.cpp +++ b/src/graph/visitor/PropertyTrackerVisitor.cpp @@ -279,8 +279,10 @@ void PropertyTrackerVisitor::visit(AttributeExpression *expr) { } void PropertyTrackerVisitor::visit(FunctionCallExpression *expr) { + // length function support `STRING` input too, so we can't ignore it directly + // TODO add type info to variable to help optimize it. static const std::unordered_set ignoreFuncs = { - "src", "dst", "type", "typeid", "id", "rank", "length"}; + "src", "dst", "type", "typeid", "id", "rank" /*, "length"*/}; auto funName = expr->name(); std::transform(funName.begin(), funName.end(), funName.begin(), ::tolower); diff --git a/tests/tck/features/bugfix/NullInputOfLength.feature b/tests/tck/features/bugfix/NullInputOfLength.feature new file mode 100644 index 00000000000..3b767ac9603 --- /dev/null +++ b/tests/tck/features/bugfix/NullInputOfLength.feature @@ -0,0 +1,18 @@ +# Copyright (c) 2022 vesoft inc. All rights reserved. +# +# This source code is licensed under Apache 2.0 License. +Feature: Null input of length function + + Background: + Given a graph with space named "nba" + + Scenario: Null input of length function + When executing query: + """ + match p = (v)-[:like]->() where id(v) == 'Tim Duncan' + return length(v.player.name) as l, length(p) as lp + """ + Then the result should be, in any order: + | l | lp | + | 10 | 1 | + | 10 | 1 | diff --git a/tests/tck/features/optimizer/PrunePropertiesRule.feature b/tests/tck/features/optimizer/PrunePropertiesRule.feature index b85e1581152..21b69feadd7 100644 --- a/tests/tck/features/optimizer/PrunePropertiesRule.feature +++ b/tests/tck/features/optimizer/PrunePropertiesRule.feature @@ -439,14 +439,14 @@ Feature: Prune Properties rule | length(p) | | 1 | And the execution plan should be: - | id | name | dependencies | operator info | - | 13 | Project | 11 | | - | 11 | Limit | 5 | | - | 5 | AppendVertices | 4 | { "props": "[{\"props\":[\"_tag\"],\"tagId\":8}, {\"props\":[\"_tag\"],\"tagId\":9}, {\"props\":[\"_tag\"],\"tagId\":10}]" } | - | 4 | Traverse | 2 | {"vertexProps": "", "edgeProps": "[{\"type\": 3, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } | - | 2 | Dedup | 1 | | - | 1 | PassThrough | 3 | | - | 3 | Start | | | + | id | name | dependencies | operator info | + | 13 | Project | 11 | | + | 11 | Limit | 5 | | + | 5 | AppendVertices | 4 | { "props": "[{\"props\":[\"_tag\", \"name\", \"speciality\"],\"tagId\":8}, {\"props\":[\"_tag\", \"name\", \"age\"],\"tagId\":9}, {\"props\":[\"_tag\", \"name\"],\"tagId\":10}]" } | + | 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\"]}]" } | + | 2 | Dedup | 1 | | + | 1 | PassThrough | 3 | | + | 3 | Start | | | When profiling query: """ MATCH p = (a:player)-[e:like*1..3]->(b:player{age:39}) @@ -466,20 +466,20 @@ Feature: Prune Properties rule | "Tracy McGrady" | 1 | | "Tracy McGrady" | 3 | And the execution plan should be: - | id | name | dependencies | operator info | - | 14 | Project | 13 | | - | 13 | BiInnerJoin | 15,12 | | - | 15 | Project | 17 | | - | 17 | AppendVertices | 16 | { "props": "[{\"props\":[\"name\",\"age\"],\"tagId\":9}]" } | - | 16 | Traverse | 2 | {"vertexProps": "", "edgeProps": "[{\"type\": 3, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } | - | 2 | Dedup | 1 | | - | 1 | PassThrough | 3 | | - | 3 | Start | | | - | 12 | Project | 18 | | - | 18 | AppendVertices | 10 | { "props": "[{\"props\":[\"_tag\"],\"tagId\":10}]" } | - | 10 | Traverse | 8 | {"vertexProps": "[{\"props\":[\"name\",\"age\"],\"tagId\":9}]", "edgeProps": "[{\"type\": 4, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } | - | 8 | Argument | | | - | 9 | Start | | | + | id | name | dependencies | operator info | + | 14 | Project | 13 | | + | 13 | BiInnerJoin | 15,12 | | + | 15 | Project | 17 | | + | 17 | AppendVertices | 16 | { "props": "[{\"props\":[\"_tag\", \"name\", \"speciality\"],\"tagId\":8}, {\"props\":[\"_tag\", \"name\", \"age\"],\"tagId\":9}, {\"props\":[\"_tag\", \"name\"],\"tagId\":10}]" } | + | 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\"]}]" } | + | 2 | Dedup | 1 | | + | 1 | PassThrough | 3 | | + | 3 | Start | | | + | 12 | Project | 18 | | + | 18 | AppendVertices | 10 | { "props": "[{\"props\":[\"_tag\"],\"tagId\":10}]" } | + | 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\"]}]" } | + | 8 | Argument | | | + | 9 | Start | | | @distonly Scenario: union match