Skip to content

Commit 3541eb5

Browse files
[UT] [BugFix] Fix FineGrainedRangePredicateRule rule bug (backport #63148) (#63170)
Signed-off-by: shuming.li <ming.moriarty@gmail.com> Co-authored-by: shuming.li <ming.moriarty@gmail.com>
1 parent 1a15248 commit 3541eb5

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

fe/fe-core/src/main/java/com/starrocks/sql/optimizer/rule/transformation/FineGrainedRangePredicateRule.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,17 @@ public static List<ScalarOperator> buildRangePredicates(ColumnRefOperator curCol
322322
List<BinaryPredicateOperator> colPredicates) {
323323
BinaryPredicateOperator leftDayBeginPredicate = colPredicates.get(0);
324324
BinaryPredicateOperator rightDayEndPredicate = colPredicates.get(1);
325-
326325
BinaryType firstType = leftDayBeginPredicate.getBinaryType();
327326
BinaryType secondType = rightDayEndPredicate.getBinaryType();
328327

329328
// make sure predicate is "col >= left And col <= right"
330329
if (BinaryType.LE.equals(firstType) || BinaryType.LT.equals(firstType)) {
331330
Collections.swap(colPredicates, 0, 1);
331+
// swap left and right to keep the correct order
332+
leftDayBeginPredicate = colPredicates.get(0);
333+
rightDayEndPredicate = colPredicates.get(1);
334+
firstType = leftDayBeginPredicate.getBinaryType();
335+
secondType = rightDayEndPredicate.getBinaryType();
332336
}
333337

334338
// calculate time points first

test/sql/test_materialized_view_refresh/R/test_mv_refresh_with_date_trunc_week

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-- name: test_mv_refresh_with_multi_union1
1+
-- name: test_mv_refresh_with_date_trunc_week @slow
22
CREATE TABLE `u1` (
33
`id` int(11) NOT NULL,
44
`dt` date NOT NULL

test/sql/test_materialized_view_refresh/T/test_mv_refresh_with_date_trunc_week

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-- name: test_mv_refresh_with_multi_union1
1+
-- name: test_mv_refresh_with_date_trunc_week @slow
22

33
CREATE TABLE `u1` (
44
`id` int(11) NOT NULL,

0 commit comments

Comments
 (0)