This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 60b490313b4 [fix](nereids) adjust logical repeat property derive
(#44360)
60b490313b4 is described below
commit 60b490313b402faee1e66863da708ec069a70292
Author: feiniaofeiafei <[email protected]>
AuthorDate: Thu Jan 9 16:16:11 2025 +0800
[fix](nereids) adjust logical repeat property derive (#44360)
### What problem does this PR solve?
Problem Summary:
Before this pr, if the children of PhysicalRepeat is hash-distributed
based on a and b, and the common columns that can be extracted from the
PhysicalRepeat grouping sets are a, b, and c, the PhysicalRepeat will
output Any distribution property.
This pr allow PhysicalRepeat maintain child hash distribution property
in this situaltion.
---
.../properties/ChildOutputPropertyDeriver.java | 24 ++++++++--------------
.../properties/ChildOutputPropertyDeriverTest.java | 23 +++++++++++++++++++++
2 files changed, 32 insertions(+), 15 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriver.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriver.java
index 8f191b61286..8dc77a43f50 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriver.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriver.java
@@ -71,6 +71,7 @@ import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -372,22 +373,15 @@ public class ChildOutputPropertyDeriver extends
PlanVisitor<PhysicalProperties,
);
}
List<ExprId> orderedShuffledColumns =
distributionSpecHash.getOrderedShuffledColumns();
- if (!intersectGroupingKeys.isEmpty() &&
intersectGroupingKeys.size()
- >= Sets.newHashSet(orderedShuffledColumns).size()) {
- boolean hashColumnsChanged = false;
- for (Expression intersectGroupingKey :
intersectGroupingKeys) {
- if (!(intersectGroupingKey instanceof SlotReference)) {
- hashColumnsChanged = true;
- break;
- }
- if (!(orderedShuffledColumns.contains(((SlotReference)
intersectGroupingKey).getExprId()))) {
- hashColumnsChanged = true;
- break;
- }
- }
- if (!hashColumnsChanged) {
- return childrenOutputProperties.get(0);
+ Set<ExprId> intersectGroupingKeysId = new HashSet<>();
+ for (Expression key : intersectGroupingKeys) {
+ if (!(key instanceof SlotReference)) {
+ break;
}
+ intersectGroupingKeysId.add(((SlotReference)
key).getExprId());
+ }
+ if
(intersectGroupingKeysId.containsAll(orderedShuffledColumns)) {
+ return childrenOutputProperties.get(0);
}
}
output =
PhysicalProperties.createAnyFromHash((DistributionSpecHash)
childDistributionSpec);
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriverTest.java
b/fe/fe-core/src/test/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriverTest.java
index a39bc664e1c..8351b9f8c22 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriverTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriverTest.java
@@ -885,4 +885,27 @@ class ChildOutputPropertyDeriverTest {
PhysicalProperties result = deriver.getOutputProperties(null,
groupExpression);
Assertions.assertEquals(child, result);
}
+
+ @Test
+ void testRepeatReturnChild2() {
+ SlotReference c1 = new SlotReference(
+ new ExprId(1), "c1", TinyIntType.INSTANCE, true,
ImmutableList.of());
+ SlotReference c2 = new SlotReference(
+ new ExprId(2), "c2", TinyIntType.INSTANCE, true,
ImmutableList.of());
+ SlotReference c3 = new SlotReference(
+ new ExprId(3), "c3", TinyIntType.INSTANCE, true,
ImmutableList.of());
+ PhysicalRepeat<GroupPlan> repeat = new PhysicalRepeat<>(
+ ImmutableList.of(ImmutableList.of(c1, c2, c3),
ImmutableList.of(c1, c2), ImmutableList.of(c1, c2)),
+ ImmutableList.of(c1, c2, c3),
+ logicalProperties,
+ groupPlan
+ );
+ GroupExpression groupExpression = new GroupExpression(repeat);
+ new Group(null, groupExpression, null);
+ PhysicalProperties child = PhysicalProperties.createHash(
+ ImmutableList.of(new ExprId(1)),
ShuffleType.EXECUTION_BUCKETED);
+ ChildOutputPropertyDeriver deriver = new
ChildOutputPropertyDeriver(Lists.newArrayList(child));
+ PhysicalProperties result = deriver.getOutputProperties(null,
groupExpression);
+ Assertions.assertEquals(child, result);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]