diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AccessPathPlanCollector.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AccessPathPlanCollector.java index e525774961a3c4..48886c0773ea76 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AccessPathPlanCollector.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AccessPathPlanCollector.java @@ -222,7 +222,20 @@ public Void visitLogicalProject(LogicalProject project, Statemen Slot innerSlot = (Slot) output.child(0); Collection outerSlotAccessPaths = allSlotToAccessPaths.get( output.getExprId().asInt()); - allSlotToAccessPaths.putAll(innerSlot.getExprId().asInt(), outerSlotAccessPaths); + for (CollectAccessPathResult outerSlotAccessPath : outerSlotAccessPaths) { + List outerPath = outerSlotAccessPath.getPath(); + List replaceSlotNamePath = new ArrayList<>(); + replaceSlotNamePath.add(innerSlot.getName()); + replaceSlotNamePath.addAll(outerPath.subList(1, outerPath.size())); + allSlotToAccessPaths.put( + innerSlot.getExprId().asInt(), + new CollectAccessPathResult( + replaceSlotNamePath, + outerSlotAccessPath.isPredicate(), + outerSlotAccessPath.getType() + ) + ); + } } else { exprCollector.collect(output); } diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/PruneNestedColumnTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/PruneNestedColumnTest.java index 4ff8a82cd7cca1..5ea5fc5b3fbf97 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/PruneNestedColumnTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/PruneNestedColumnTest.java @@ -284,6 +284,31 @@ public void testProject() throws Exception { ImmutableList.of(path("s", "data", "*", "*", "b")), ImmutableList.of() ); + + createTable( + "CREATE TABLE `view_baseall_drop_nereids` (\n" + + " `k1` int(11) NULL,\n" + + " `k3` array NULL\n" + + " ) ENGINE=OLAP\n" + + " DUPLICATE KEY(`k1`)\n" + + " COMMENT 'OLAP'\n" + + " DISTRIBUTED BY HASH(`k1`) BUCKETS 5\n" + + " PROPERTIES (\n" + + " \"replication_allocation\" = \"tag.location.default: 1\",\n" + + " \"is_being_synced\" = \"false\",\n" + + " \"storage_format\" = \"V2\",\n" + + " \"light_schema_change\" = \"true\",\n" + + " \"disable_auto_compaction\" = \"false\",\n" + + " \"enable_single_replica_compaction\" = \"false\"\n" + + " )" + ); + createView("create view IF NOT EXISTS test_view7_drop_nereids (k1,k2,k3,k4) as\n" + + " select *, array_filter(x->x>0,k3),array_filter(`k3`, array_map(x -> x > 0, `k3`)) from view_baseall_drop_nereids order by k1"); + assertColumn("select * from test_view7_drop_nereids order by k1", + "array", + ImmutableList.of(path("k3")), + ImmutableList.of() + ); } @Test