From 5bd78028cbc1cb0bb32267a6bcbbbd47c89e4730 Mon Sep 17 00:00:00 2001 From: 924060929 Date: Tue, 17 Dec 2024 20:58:23 +0800 Subject: [PATCH] fix --- .../rules/PartitionPredicateToRange.java | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/PartitionPredicateToRange.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/PartitionPredicateToRange.java index 3718391ba3a66a9..fca62195a2e0690 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/PartitionPredicateToRange.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/PartitionPredicateToRange.java @@ -152,7 +152,7 @@ public RangeSet visitNullSafeEqual(NullSafeEqual nullSafeEqual Expression right = nullSafeEqual.right(); if (left instanceof SlotReference && right instanceof Literal) { if (slotIds.contains(((SlotReference) left).getExprId().asInt())) { - Range singleton = ColumnBound.singleton(new NullLiteral(left.getDataType())); + Range singleton = ColumnBound.singleton((Literal) right); return toRangeSet((SlotReference) left, singleton, BoundType.CLOSED, BoundType.CLOSED); } } @@ -187,8 +187,10 @@ public RangeSet visitLessThan(LessThan lessThan, Void context) Expression right = lessThan.right(); if (left instanceof SlotReference && right instanceof Literal) { if (slotIds.contains(((SlotReference) left).getExprId().asInt())) { - Range singleton = ColumnBound.singleton((Literal) right); - return toRangeSet((SlotReference) left, singleton, BoundType.CLOSED, BoundType.OPEN); + Range columnRange = ColumnBound.range( + new NullLiteral(right.getDataType()), BoundType.CLOSED, (Literal) right, BoundType.OPEN + ); + return toRangeSet((SlotReference) left, columnRange, BoundType.CLOSED, BoundType.OPEN); } } return null; @@ -200,8 +202,10 @@ public RangeSet visitLessThanEqual(LessThanEqual lessThanEqual Expression right = lessThanEqual.right(); if (left instanceof SlotReference && right instanceof Literal) { if (slotIds.contains(((SlotReference) left).getExprId().asInt())) { - Range singleton = ColumnBound.singleton((Literal) right); - return toRangeSet((SlotReference) left, singleton, BoundType.CLOSED, BoundType.CLOSED); + Range columnRange = ColumnBound.range( + new NullLiteral(right.getDataType()), BoundType.CLOSED, (Literal) right, BoundType.CLOSED + ); + return toRangeSet((SlotReference) left, columnRange, BoundType.CLOSED, BoundType.CLOSED); } } return null; @@ -213,8 +217,10 @@ public RangeSet visitGreaterThan(GreaterThan greaterThan, Void Expression right = greaterThan.right(); if (left instanceof SlotReference && right instanceof Literal) { if (slotIds.contains(((SlotReference) left).getExprId().asInt())) { - Range singleton = ColumnBound.singleton((Literal) right); - return toRangeSet((SlotReference) left, singleton, BoundType.OPEN, BoundType.CLOSED); + Range columnRange = ColumnBound.range( + (Literal) right, BoundType.OPEN, new MaxLiteral(right.getDataType()), BoundType.CLOSED + ); + return toRangeSet((SlotReference) left, columnRange, BoundType.OPEN, BoundType.CLOSED); } } return null; @@ -226,8 +232,10 @@ public RangeSet visitGreaterThanEqual(GreaterThanEqual greater Expression right = greaterThanEqual.right(); if (left instanceof SlotReference && right instanceof Literal) { if (slotIds.contains(((SlotReference) left).getExprId().asInt())) { - Range singleton = ColumnBound.singleton((Literal) right); - return toRangeSet((SlotReference) left, singleton, BoundType.CLOSED, BoundType.CLOSED); + Range columnRange = ColumnBound.range( + (Literal) right, BoundType.CLOSED, new MaxLiteral(right.getDataType()), BoundType.CLOSED + ); + return toRangeSet((SlotReference) left, columnRange, BoundType.CLOSED, BoundType.CLOSED); } } return null; @@ -248,7 +256,7 @@ private RangeSet toRangeSet( } } MultiColumnBound lowerBound = new MultiColumnBound(lowerBounds); - MultiColumnBound upperBound = new MultiColumnBound(lowerBounds); + MultiColumnBound upperBound = new MultiColumnBound(upperBounds); Range range = Range.range(lowerBound, lowerBoundType, upperBound, upperBoundType); return ImmutableRangeSet.of(range);