Skip to content

Commit 7d2c798

Browse files
committed
docs: clarify epoch extraction behavior for intervals
1 parent bc2371c commit 7d2c798

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

datafusion/functions/src/datetime/date_part.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ use datafusion_macros::user_doc;
7373
- nanosecond
7474
- dow (day of the week where Sunday is 0)
7575
- doy (day of the year)
76-
- epoch (seconds since Unix epoch)
76+
- epoch (seconds since Unix epoch for timestamps/dates, total seconds for intervals)
7777
- isodow (day of the week where Monday is 0)
7878
"#
7979
),
@@ -352,6 +352,10 @@ fn seconds(array: &dyn Array, unit: TimeUnit) -> Result<ArrayRef> {
352352

353353
fn epoch(array: &dyn Array) -> Result<ArrayRef> {
354354
const SECONDS_IN_A_DAY: f64 = 86400_f64;
355+
// Note: Month-to-second conversion uses 30 days as an approximation.
356+
// This matches PostgreSQL's behavior for interval epoch extraction,
357+
// but does not represent exact calendar months (which vary 28-31 days).
358+
// See: https://doxygen.postgresql.org/datatype_2timestamp_8h.html
355359
const DAYS_PER_MONTH: f64 = 30_f64;
356360

357361
let f: Float64Array = match array.data_type() {

0 commit comments

Comments
 (0)