findepi commented on code in PR #16859:
URL: https://github.com/apache/datafusion/pull/16859#discussion_r2229264131
##########
datafusion/functions/src/datetime/date_trunc.rs:
##########
@@ -185,6 +187,21 @@ impl ScalarUDFImpl for DateTruncFunc {
) -> Result<ColumnarValue> {
let parsed_tz = parse_tz(tz_opt)?;
let array = as_primitive_array::<T>(array)?;
+
+ // fast path for fine granularities
+ if matches!(
+ granularity.as_str(),
+ "second" | "minute" | "millisecond" | "microsecond"
+ ) || (parsed_tz.is_none() && granularity.as_str() == "hour")
+ {
+ let result = general_date_trunc_array_fine_granularity(
Review Comment:
You're right. For minute and smaller granularities the new code path is
always fine¹
For hour it's also fine, for zone-less data.
- (¹) in the past (early XX century and earlier) named zones often had
offset changes not multiple of minutes at list this is what
https://www.timeanddate.com/time/zone/nepal/kathmandu shows me. Not sure
whether chrono respects that
<img width="831" height="259" alt="image"
src="https://github.com/user-attachments/assets/eea59fb7-02e2-4613-9be1-e248865b2a92"
/>
- for zone-less data (timestamp without time zone), day granularity can also
be applied with just divide and mul, just like hour. Or am i blind again?
--
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]