diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java b/fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java index e7de94e957..0341ee0e0e 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java +++ b/fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java @@ -57,6 +57,7 @@ import org.apache.commons.collections.CollectionUtils; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashSet; import java.util.List; import java.util.Set; @@ -628,6 +629,16 @@ public abstract class PlanNode extends TreeNode implements PlanStats { if (!analyzer.safeIsEnableJoinReorderBasedCost()) { computeOldCardinality(); } + for (Expr expr : conjuncts) { + Set slotRefs = new HashSet<>(); + expr.getSlotRefsBoundByTupleIds(tupleIds, slotRefs); + for (SlotRef slotRef : slotRefs) { + slotRef.getDesc().setIsMaterialized(true); + } + for (TupleId tupleId : tupleIds) { + analyzer.getTupleDesc(tupleId).computeMemLayout(); + } + } } protected void computeNumNodes() { diff --git a/regression-test/data/query_p0/lateral_view/test_with_view.out b/regression-test/data/query_p0/lateral_view/test_with_view.out new file mode 100644 index 0000000000..9c9c4c6c8a --- /dev/null +++ b/regression-test/data/query_p0/lateral_view/test_with_view.out @@ -0,0 +1,3 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !sql -- + diff --git a/regression-test/suites/query_p0/lateral_view/test_with_view.groovy b/regression-test/suites/query_p0/lateral_view/test_with_view.groovy new file mode 100644 index 0000000000..e1ef938bc4 --- /dev/null +++ b/regression-test/suites/query_p0/lateral_view/test_with_view.groovy @@ -0,0 +1,35 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +suite("lateral_view_with_inline_view") { + sql """DROP TABLE IF EXISTS t1;""" + sql """CREATE TABLE t1 (col1 varchar(11451) not null, col2 int not null, col3 int not null, col4 int not null) + UNIQUE KEY(`col1`) + DISTRIBUTED BY HASH(col1) + BUCKETS 3 + PROPERTIES( + "replication_num"="1" + );""" + qt_sql """ + select example1.col1 + from + (select col1,`col4`,col2 + from t1 where col3<=115411) + example1 lateral view explode([1,2,3]) tmp1 as e1 where col4