Skip to content

Commit 7b45bc3

Browse files
[fix](nereids)fix rangeSet intersect in PartitionPredicateToRange (#46087)
1 parent 6589a2e commit 7b45bc3

File tree

2 files changed

+73
-7
lines changed

2 files changed

+73
-7
lines changed

fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/PartitionPredicateToRange.java

+9-7
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,7 @@ public RangeSet<MultiColumnBound> visitAnd(And and, Void context) {
8484
intersects = childRanges;
8585
continue;
8686
}
87-
88-
for (Range<MultiColumnBound> childRange : childRanges.asRanges()) {
89-
intersects = intersects.subRangeSet(childRange);
90-
if (intersects.isEmpty()) {
91-
break;
92-
}
93-
}
87+
intersects = intersection(childRanges, intersects);
9488
if (intersects.isEmpty()) {
9589
break;
9690
}
@@ -264,4 +258,12 @@ private RangeSet<MultiColumnBound> toRangeSet(SlotReference slotReference,
264258
Range<MultiColumnBound> range = Range.range(lowerBound, lowerBoundType, upperBound, upperBoundType);
265259
return ImmutableRangeSet.of(range);
266260
}
261+
262+
public static <T extends Comparable<?>> RangeSet<T> intersection(RangeSet<T> rangeSet1, RangeSet<T> rangeSet2) {
263+
RangeSet<T> result = TreeRangeSet.create();
264+
for (Range<T> range : rangeSet1.asRanges()) {
265+
result.addAll(rangeSet2.subRangeSet(range));
266+
}
267+
return result;
268+
}
267269
}

0 commit comments

Comments
 (0)