namanjain24-sudo commented on code in PR #25498:
URL: https://github.com/apache/datafusion/pull/25498#discussion_r4054289298


##########
datafusion/functions/src/datetime/date_trunc.rs:
##########
@@ -796,13 +772,8 @@ fn general_date_trunc_array_fine_granularity<T: 
ArrowTimestampType>(
             })
             .collect();
         let array: PrimitiveArray<T> = if maybe_underflow {
-            array.try_unary(|value| {
-                value.checked_sub(value.rem_euclid(unit)).ok_or_else(|| {
-                    exec_datafusion_err!(
-                        "Timestamp {value} out of range after truncating to 
{granularity}"
-                    )
-                })
-            })?
+            array
+                .try_unary(|value| date_trunc_fine_granularity(tu, value, 
granularity))?

Review Comment:
   Good catch, agreed. In 5c830eb the slow branch now passes the `unit` it 
already has to a small `truncate_to_unit(value, unit, granularity)`, and the 
scalar path looks the unit up once, so `date_trunc_fine_granularity` is gone.



-- 
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]

Reply via email to