Skip to content

Commit 9a61c00

Browse files
committed
Week intervals support
1 parent 367eeb2 commit 9a61c00

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

datafusion/src/sql/planner.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,6 +1582,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
15821582
)));
15831583
}
15841584

1585+
const DAYS_PER_WEEK: f32 = 7_f32;
15851586
const SECONDS_PER_HOUR: f32 = 3_600_f32;
15861587
const MILLIS_PER_SECOND: f32 = 1_000_f32;
15871588

@@ -1629,6 +1630,11 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
16291630
match interval_type.to_lowercase().as_str() {
16301631
"year" => Ok(align_interval_parts(interval_period * 12_f32, 0.0, 0.0)),
16311632
"month" => Ok(align_interval_parts(interval_period, 0.0, 0.0)),
1633+
"week" | "weeks" => Ok(align_interval_parts(
1634+
0.0,
1635+
interval_period * DAYS_PER_WEEK,
1636+
0.0,
1637+
)),
16321638
"day" | "days" => Ok(align_interval_parts(0.0, interval_period, 0.0)),
16331639
"hour" | "hours" => {
16341640
Ok((0, 0, interval_period * SECONDS_PER_HOUR * MILLIS_PER_SECOND))

0 commit comments

Comments
 (0)