Is your feature request related to a problem or challenge? Please describe what you are trying to do.
In DataFusion we have occasions where we have a chrono NiaveDateTime or DateTime and would like to create the corresponding Timestamp value (e.g. i64)
This came up recently in https://github.com/apache/datafusion/pull/19733/changes#r2742968186\\
Basically we want the API
fn date_to_scalar(date: NaiveDate, target_type: &DataType) -> Option<ScalarValue> {
We have Date32Type::from_naive_date(date) but couldn't find the equivalent of Timestamp types as well
I was hoping for something like TimestampSecondType::from_datetime or something but all I could find was
https://docs.rs/arrow/latest/arrow/array/types/struct.TimestampSecondType.html and https://docs.rs/arrow/latest/arrow/datatypes/trait.ArrowTimestampType.html
Instead we went with our own date/time parsing (see apache/datafusion#19733)
Describe the solution you'd like
Add an API so downstream crates can avoid having to do date/time/timestamp arithmetic to convert from a NiaveDate (or document the conversion better)
Describe alternatives you've considered
Additional context
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
In DataFusion we have occasions where we have a chrono
NiaveDateTimeorDateTimeand would like to create the correspondingTimestampvalue (e.g. i64)This came up recently in https://github.com/apache/datafusion/pull/19733/changes#r2742968186\\
Basically we want the API
We have
Date32Type::from_naive_date(date)but couldn't find the equivalent of Timestamp types as wellI was hoping for something like
TimestampSecondType::from_datetimeor something but all I could find washttps://docs.rs/arrow/latest/arrow/array/types/struct.TimestampSecondType.html and https://docs.rs/arrow/latest/arrow/datatypes/trait.ArrowTimestampType.html
Instead we went with our own date/time parsing (see apache/datafusion#19733)
Describe the solution you'd like
Add an API so downstream crates can avoid having to do date/time/timestamp arithmetic to convert from a NiaveDate (or document the conversion better)
Describe alternatives you've considered
Additional context