This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new afeff5daeed branch-2.1: [fix](nereids) fix bug in
PhysicalTopN.equals() #46547 (#46633)
afeff5daeed is described below
commit afeff5daeed2f0dbec74ee6cc2e4c453c71035e5
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Jan 9 10:28:40 2025 +0800
branch-2.1: [fix](nereids) fix bug in PhysicalTopN.equals() #46547 (#46633)
Cherry-picked from #46547
Co-authored-by: minghong <[email protected]>
---
.../nereids/trees/plans/physical/PhysicalTopN.java | 4 +-
.../trees/plans/physical/PhysicalTopNTest.java | 55 ++++++++++++++++++++++
2 files changed, 58 insertions(+), 1 deletion(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalTopN.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalTopN.java
index 96dc709bbde..0f2d3186580 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalTopN.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalTopN.java
@@ -92,7 +92,9 @@ public class PhysicalTopN<CHILD_TYPE extends Plan> extends
AbstractPhysicalSort<
return false;
}
PhysicalTopN<?> that = (PhysicalTopN<?>) o;
- return limit == that.limit && offset == that.offset;
+ return limit == that.limit && offset == that.offset
+ && this.phase == that.phase
+ && Objects.equals(that.getOrderKeys(), getOrderKeys());
}
@Override
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/physical/PhysicalTopNTest.java
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/physical/PhysicalTopNTest.java
new file mode 100644
index 00000000000..c411ad44619
--- /dev/null
+++
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/physical/PhysicalTopNTest.java
@@ -0,0 +1,55 @@
+// 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.trees.plans.physical;
+
+import org.apache.doris.nereids.properties.OrderKey;
+import org.apache.doris.nereids.trees.expressions.ExprId;
+import org.apache.doris.nereids.trees.expressions.SlotReference;
+import org.apache.doris.nereids.trees.plans.Plan;
+import org.apache.doris.nereids.trees.plans.SortPhase;
+import org.apache.doris.nereids.types.BigIntType;
+
+import com.google.common.collect.Lists;
+import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+
+public class PhysicalTopNTest {
+ @Test
+ public void testEquals(@Mocked Plan child) {
+ SlotReference a = new SlotReference(new ExprId(0), "a",
+ BigIntType.INSTANCE, true, Lists.newArrayList());
+ List<OrderKey> orderKeysA = Lists.newArrayList();
+ orderKeysA.add(new OrderKey(a, true, true));
+ PhysicalTopN topn1 = new PhysicalTopN(orderKeysA, 1, 1,
SortPhase.LOCAL_SORT,
+ null, child);
+ PhysicalTopN topn2 = new PhysicalTopN(orderKeysA, 1, 1,
SortPhase.GATHER_SORT,
+ null, child);
+ Assertions.assertNotEquals(topn1, topn2);
+
+ SlotReference b = new SlotReference(new ExprId(0), "b",
+ BigIntType.INSTANCE, true, Lists.newArrayList());
+ List<OrderKey> orderKeysB = Lists.newArrayList();
+ orderKeysB.add(new OrderKey(b, true, true));
+ PhysicalTopN topn3 = new PhysicalTopN(orderKeysB, 1, 1,
SortPhase.LOCAL_SORT,
+ null, child);
+ Assertions.assertNotEquals(topn2, topn3);
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]