Skip to content

Commit 6a213a7

Browse files
Describe what each date_trunc test case covers
Co-Authored-By: Claude Sonnet 5 <[email protected]>
1 parent 5c830eb commit 6a213a7

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎datafusion/functions/src/datetime/date_trunc.rs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,6 +1508,7 @@ mod tests {
15081508
let seconds = 10_000_000_000;
15091509
let utc: Option<Arc<str>> = Some("UTC".into());
15101510
let cases = [
1511+
// Seconds, truncated to a minute, an hour and a day
15111512
(
15121513
ScalarValue::TimestampSecond(Some(seconds + 59), None),
15131514
"minute",
@@ -1517,11 +1518,14 @@ mod tests {
15171518
"hour",
15181519
),
15191520
(ScalarValue::TimestampSecond(Some(seconds + 1), None), "day"),
1521+
// The granularity is the input's own unit
15201522
(ScalarValue::TimestampSecond(Some(seconds), None), "second"),
1523+
// With a time zone
15211524
(
15221525
ScalarValue::TimestampSecond(Some(seconds + 59), utc.clone()),
15231526
"minute",
15241527
),
1528+
// Milliseconds and microseconds, truncated to a coarser unit
15251529
(
15261530
ScalarValue::TimestampMillisecond(Some(seconds * 1_000 + 999), None),
15271531
"second",
@@ -1530,6 +1534,7 @@ mod tests {
15301534
ScalarValue::TimestampMicrosecond(Some(seconds * 1_000_000 + 999), None),
15311535
"millisecond",
15321536
),
1537+
// Before the epoch, with a time zone
15331538
(
15341539
ScalarValue::TimestampMicrosecond(Some(-seconds * 1_000_000 - 1), utc),
15351540
"second",

0 commit comments

Comments
 (0)