mbutrovich commented on issue #14738:
URL: https://github.com/apache/datafusion/issues/14738#issuecomment-6384741651
#26686 removes the wrapped value and the debug panic, but it doesn't give
the Postgres result for the reproducer:
```sql
SELECT date_part('microsecond', timestamp '1970-01-01T00:40:00' - timestamp
'1970-01-01T00:00:00');
-- NULL
```
In Postgres the difference is an interval, so `microsecond` is the seconds
field within the minute (0 here). In DataFusion it is a `Duration`, and #26686
treats `millisecond`, `microsecond` and `nanosecond` of a `Duration` as its
total length, the way arrow's `date_part` treats the other `Duration` parts.
2.4e9 microseconds don't fit in the `Int32` result, so the result is NULL. That
makes any `Duration` over about 35.8 minutes NULL for `microsecond`, and over
about 24.8 days for `millisecond`.
On the [dev
list](https://lists.apache.org/thread.html/90cqgs9dotp39tcwr5ophvb2ftvjc43p),
@alamb agreed that NULL is fine for now and suggested following Postgres where
we can. Postgres has no `Duration` type, so following it here means giving
`Duration` the interval meaning: seconds within the minute, hours within the
day. That would change every `Duration` part, not only the sub-second ones,
because arrow's `date_part` returns the total for [`hour`, `minute` and
`second`](https://github.com/apache/arrow-rs/blob/9d7f294ca6bfa3591616059d11a3c15464a21f58/arrow-arith/src/temporal.rs#L662-L669)
as well. Should `Duration` parts take the interval meaning, or keep the total
length?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]