diff --git a/src/graph/visitor/PrunePropertiesVisitor.cpp b/src/graph/visitor/PrunePropertiesVisitor.cpp index 166cfc81bb7..bf4c2ec9c97 100644 --- a/src/graph/visitor/PrunePropertiesVisitor.cpp +++ b/src/graph/visitor/PrunePropertiesVisitor.cpp @@ -441,7 +441,11 @@ void PrunePropertiesVisitor::visit(Unwind *node) { void PrunePropertiesVisitor::visitCurrent(Unwind *node) { const auto &alias = node->alias(); - if (propsUsed_.hasAlias(alias)) { + auto expr = node->unwindExpr(); + auto kind = expr->kind(); + // unwind e.start_year as a + if (propsUsed_.hasAlias(alias) || + (kind != Expression::Kind::kVarProperty && kind != Expression::Kind::kInputProperty)) { status_ = extractPropsFromExpr(node->unwindExpr()); if (!status_.ok()) { return; diff --git a/tests/tck/features/optimizer/PrunePropertiesRule.feature b/tests/tck/features/optimizer/PrunePropertiesRule.feature index 242693977c2..7d3835a10f4 100644 --- a/tests/tck/features/optimizer/PrunePropertiesRule.feature +++ b/tests/tck/features/optimizer/PrunePropertiesRule.feature @@ -1,7 +1,6 @@ # Copyright (c) 2021 vesoft inc. All rights reserved. # # This source code is licensed under Apache 2.0 License. -@jmq Feature: Prune Properties rule # The schema id is not fixed in standalone cluster, so we skip it @@ -549,27 +548,27 @@ Feature: Prune Properties rule | "Spurs" | 11 | | "Hornets" | 3 | And the execution plan should be: - | id | name | dependencies | operator info | - | 21 | Aggregate | 20 | | - | 20 | Aggregate | 19 | | - | 19 | HashLeftJoin | 10, 25 | | - | 10 | Aggregate | 23 | | - | 23 | Project | 22 | | - | 22 | Filter | 29 | | - | 29 | AppendVertices | 28 | { "props": "[{\"props\":[\"name\", \"_tag\"],\"tagId\": 4}]" } | - | 28 | Traverse | 27 | {"vertexProps": "[{\"props\":[\"name\", \"age\", \"_tag\"],\"tagId\": 3}, {\"props\":[\"name\", \"speciality\", \"_tag\"],\"tagId\": 5}, {\"props\":[\"name\", \"_tag\"],\"tagId\": 4}]", "edgeProps": "[{\"type\": 7, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } | - | 27 | Traverse | 26 | {"vertexProps": "", "edgeProps": "[{\"type\": -8, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } | - | 26 | Traverse | 2 | {"vertexProps": "", "edgeProps": "[{\"type\": -6, \"props\": [\"_type\", \"_rank\", \"_dst\"]}, {\"type\": 6, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } | - | 2 | Dedup | 1 | | - | 1 | PassThrough | 3 | | - | 3 | Start | | | - | 25 | Project | 24 | | - | 24 | Filter | 16 | | - | 16 | AppendVertices | 15 | { "props": "[{\"props\":[\"name\", \"_tag\"],\"tagId\": 4}]" } | - | 15 | Traverse | 14 | {"vertexProps": "[{\"props\":[\"name\", \"age\", \"_tag\"],\"tagId\": 3}, {\"props\":[\"name\", \"speciality\", \"_tag\"],\"tagId\": 5}, {\"props\":[\"name\", \"_tag\"],\"tagId\": 4}]", "edgeProps": "[{\"type\": 7, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } | - | 14 | Traverse | 13 | {"vertexProps": "", "edgeProps": "[{\"type\": -6, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } | - | 13 | Traverse | 11 | {"vertexProps": "", "edgeProps": "[{\"type\": -6, \"props\": [\"_type\", \"_rank\", \"_dst\"]}, {\"type\": 6, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } | - | 11 | Argument | | | + | id | name | dependencies | operator info | + | 21 | Aggregate | 20 | | + | 20 | Aggregate | 19 | | + | 19 | HashLeftJoin | 10, 25 | | + | 10 | Aggregate | 23 | | + | 23 | Project | 22 | | + | 22 | Filter | 29 | | + | 29 | AppendVertices | 28 | { "props": "[{\"tagId\":3,\"props\":[\"name\",\"age\",\"_tag\"]},{\"props\":[\"name\",\"speciality\",\"_tag\"],\"tagId\":5},{\"tagId\":4,\"props\":[\"name\",\"_tag\"]}]" } | + | 28 | Traverse | 27 | {"vertexProps": "[{\"props\":[\"age\"],\"tagId\": 3}]", "edgeProps": "[{\"type\": 7, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } | + | 27 | Traverse | 26 | {"vertexProps": "", "edgeProps": "[{\"type\": -8, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } | + | 26 | Traverse | 2 | {"vertexProps": "[{\"tagId\":3,\"props\":[\"name\",\"age\",\"_tag\"]},{\"props\":[\"name\",\"speciality\",\"_tag\"],\"tagId\":5},{\"tagId\":4,\"props\":[\"name\",\"_tag\"]}]", "edgeProps": "[{\"type\": -6, \"props\": [\"_type\", \"_rank\", \"_dst\"]}, {\"type\": 6, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } | + | 2 | Dedup | 1 | | + | 1 | PassThrough | 3 | | + | 3 | Start | | | + | 25 | Project | 24 | | + | 24 | Filter | 16 | | + | 16 | AppendVertices | 15 | { "props": "[{\"tagId\":3,\"props\":[\"name\",\"age\",\"_tag\"]},{\"props\":[\"name\",\"speciality\",\"_tag\"],\"tagId\":5},{\"tagId\":4,\"props\":[\"name\",\"_tag\"]}]"} | + | 15 | Traverse | 14 | {"vertexProps": "[{\"props\":[\"age\"],\"tagId\": 3}]", "edgeProps": "[{\"type\": 7, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } | + | 14 | Traverse | 13 | {"vertexProps": "", "edgeProps": "[{\"type\": -6, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } | + | 13 | Traverse | 11 | {"vertexProps": "[{\"tagId\":3,\"props\":[\"name\",\"age\",\"_tag\"]},{\"props\":[\"name\",\"speciality\",\"_tag\"],\"tagId\":5},{\"tagId\":4,\"props\":[\"name\",\"_tag\"]}]", "edgeProps": "[{\"type\": -6, \"props\": [\"_type\", \"_rank\", \"_dst\"]}, {\"type\": 6, \"props\": [\"_type\", \"_rank\", \"_dst\"]}]" } | + | 11 | Argument | | | @distonly Scenario: test properties: