Skip to content

Commit

Permalink
add regression cases
Browse files Browse the repository at this point in the history
  • Loading branch information
feiniaofeiafei committed Dec 17, 2024
1 parent 3964e77 commit e14e305
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -310,4 +310,35 @@ suite("test_add_sub_diff_ceil_floor") {
cast(date_add('2022-01-01 00:00:00', interval number month) as date), cast(number as varchar(65533)) FROM numbers('number'='100');"""
sql "INSERT INTO max_t values(3,null,null,null);"

explain {
sql "select * from max_t where years_diff('2021-01-01',month_ceil(hours_add(dt, 1),'1990-01-05')) <=2 ;"
contains("partitions=5/6 (p2,p3,p4,p5,p6)")
}
explain {
sql "select * from max_t where years_diff('2021-01-01',month_ceil(hours_add(dt, 1),10,'1990-01-05')) <=2 ;"
contains("partitions=5/6 (p2,p3,p4,p5,p6)")
}

explain {
sql """select * from max_t where years_diff('2021-01-01',month_ceil(hours_add(dt, 1),10,'1990-01-05')) <=2 and dt >'2018-01-01';"""
contains("partitions=4/6 (p3,p4,p5,p6)")
}

explain {
sql """select * from max_t where months_diff('2021-01-01',month_floor(hours_add(dt, 1),10,'1990-01-05')) <=2;"""
contains("partitions=3/6 (p1,p5,p6)")
}

explain {
sql """select * from max_t where months_diff('2021-01-01',month_floor(hours_add(dt, 1),12,'1000-01-01')) > 2"""
contains("partitions=5/6 (p1,p2,p3,p4,p5)")
}
explain {
sql """select * from max_t where months_diff('2021-01-01',month_floor(hours_add(dt, 1),12,'1000-01-01')) > 2 and month_floor(dt) >'2018-01-01' """
contains("partitions=3/6 (p3,p4,p5)")
}
explain {
sql """select * from max_t where hours_sub(hours_add(dt, 1),1) >'2018-01-01' and days_diff(hours_sub(hours_add(dt, 1),1),'2021-01-01') >2"""
contains("partitions=1/6 (p6)")
}
}

0 comments on commit e14e305

Please sign in to comment.