yujun777 commented on code in PR #65472:
URL: https://github.com/apache/doris/pull/65472#discussion_r3628040024
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalFileScan.java:
##########
@@ -197,6 +197,15 @@ public boolean equals(Object o) {
return super.equals(o) && Objects.equals(selectedPartitions,
((LogicalFileScan) o).selectedPartitions);
}
+ @Override
+ protected boolean hasSameScanState(LogicalCatalogRelation other) {
Review Comment:
Fixed in commit d6eb5ec2451. LogicalHudiScan now overrides
hasSameScanState() and compares the effective incrementalRelation in addition
to the inherited file-scan state. Added FE UT coverage for equal and different
incremental relations; PullUpJoinFromUnionAllTest passes all 19 tests.
##########
fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/PullUpJoinFromUnionAllTest.java:
##########
@@ -0,0 +1,458 @@
+// 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.
+
+package org.apache.doris.nereids.rules.rewrite;
+
+import org.apache.doris.analysis.TableScanParams;
+import org.apache.doris.analysis.TableSnapshot;
+import org.apache.doris.catalog.Column;
+import org.apache.doris.catalog.KeysType;
+import org.apache.doris.catalog.OdbcTable;
+import org.apache.doris.catalog.OlapTable;
+import org.apache.doris.catalog.Type;
+import org.apache.doris.catalog.stream.OlapTableStreamWrapper;
+import org.apache.doris.catalog.stream.StreamReadMode;
+import org.apache.doris.common.Pair;
+import org.apache.doris.datasource.ExternalTable;
+import org.apache.doris.nereids.trees.expressions.Alias;
+import org.apache.doris.nereids.trees.expressions.EqualTo;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.NamedExpression;
+import org.apache.doris.nereids.trees.expressions.Slot;
+import org.apache.doris.nereids.trees.expressions.SlotReference;
+import org.apache.doris.nereids.trees.plans.JoinType;
+import org.apache.doris.nereids.trees.plans.Plan;
+import org.apache.doris.nereids.trees.plans.RelationId;
+import org.apache.doris.nereids.trees.plans.algebra.SetOperation.Qualifier;
+import org.apache.doris.nereids.trees.plans.logical.LogicalFileScan;
+import org.apache.doris.nereids.trees.plans.logical.LogicalFilter;
+import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
+import org.apache.doris.nereids.trees.plans.logical.LogicalOdbcScan;
+import org.apache.doris.nereids.trees.plans.logical.LogicalOlapScan;
+import org.apache.doris.nereids.trees.plans.logical.LogicalOlapTableStreamScan;
+import org.apache.doris.nereids.trees.plans.logical.LogicalProject;
+import org.apache.doris.nereids.trees.plans.logical.LogicalSchemaScan;
+import org.apache.doris.nereids.trees.plans.logical.LogicalTestScan;
+import org.apache.doris.nereids.trees.plans.logical.LogicalUnion;
+import org.apache.doris.nereids.util.MemoTestUtils;
+import org.apache.doris.nereids.util.PlanChecker;
+import org.apache.doris.nereids.util.PlanConstructor;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+
+class PullUpJoinFromUnionAllTest {
+
+ @Test
+ void comparatorRejectsDifferentProjectOutputSizes() {
+ LogicalOlapScan smallScan = newScan(1, "common_small");
+ LogicalOlapScan largeScan = newScan(1, "common_large");
+ LogicalProject<LogicalOlapScan> smallProject =
project(selectSlots(smallScan.getOutput(), 0), smallScan);
+ LogicalProject<LogicalOlapScan> largeProject =
project(selectSlots(largeScan.getOutput(), 0, 1), largeScan);
+
+ PullUpJoinFromUnionAll.LogicalPlanComparator comparator =
+ new PullUpJoinFromUnionAll().new LogicalPlanComparator();
+ Assertions.assertFalse(comparator.isLogicalEqual(largeProject,
smallProject));
+ }
+
+ @Test
+ void comparatorRejectsDifferentFilterChildOutputSizes() {
+ LogicalFilter<LogicalOlapScan> smallFilter =
filter(newCachedOutputScan(1, "common_filter", 0));
+ LogicalFilter<LogicalOlapScan> largeFilter =
filter(newCachedOutputScan(1, "common_filter", 0, 1));
+
+ PullUpJoinFromUnionAll.LogicalPlanComparator comparator =
+ new PullUpJoinFromUnionAll().new LogicalPlanComparator();
+ Assertions.assertFalse(comparator.isLogicalEqual(largeFilter,
smallFilter));
+ }
+
+ @Test
+ void comparatorRejectsDifferentMaterializedIndexSelections() {
+ PullUpJoinFromUnionAll.LogicalPlanComparator comparator =
+ new PullUpJoinFromUnionAll().new LogicalPlanComparator();
+ LogicalOlapScan baseScan = newScanWithExtraIndex(11, "common_index",
101);
+ LogicalOlapScan indexScan =
baseScan.withMaterializedIndexSelected(101);
+
+ Assertions.assertFalse(comparator.isLogicalEqual(baseScan, indexScan));
+ }
+
+ @Test
+ void comparatorRejectsDifferentManuallySpecifiedPartitions() {
+ LogicalOlapScan firstPartitionScan =
PlanConstructor.newLogicalOlapScanWithSameId(
Review Comment:
Fixed in commit d6eb5ec2451. The partition test now uses an OlapTable with
real mocked partitions (IDs 1 and 2), constructs both scans with the same table
and calls withSelectedPartitionIds() explicitly, so the comparator observes
different selectedPartitionIds rather than only differing manual partition
metadata. PullUpJoinFromUnionAllTest passes all 19 tests.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]