Avoid from_num_days_from_ce_opt
calls in timestamp_s_to_datetime
if we don't need
#6746
Labels
enhancement
Any new improvement worthy of a entry in the changelog
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
Describe the solution you'd like
In Arrow-rs, extracting the minute from a timestamp involves converting the timestamp, such as
1599563412
, into aNaiveDateTime
using thetimestamp_s_to_datetime
function. This results in a value like2020-09-08T12:10:12.123456780
. Theminute()
method is then called on the NaiveDateTime to retrieve the minute component, such as10
.However, in chrono's implementation, even when only the minute is required using
NaiveTime::from_num_seconds_from_midnight_opt
, the functionNaiveTime::from_num_days_from_ce_opt
is still called. Ideally, this additional step should be avoided to improve efficiency.I propose we upstream chrono crate and find a way to get
date
andtime
separately givensecs: i64, nsecs: u32
. Then we call corresponding smaller function based on what we need to minimum the cost.Describe alternatives you've considered
Additional context
This is the flamegraph for clickbench Q18 in datafusion, we can see the
from_num_days_from_ce_opt
spent much time fordate_part
function. But the query care only aboutminute
so the compute offrom_num_days_from_ce_opt
is useless.The text was updated successfully, but these errors were encountered: