sdf-jkl commented on code in PR #19733:
URL: https://github.com/apache/datafusion/pull/19733#discussion_r2743833522
##########
datafusion/functions/src/datetime/date_part.rs:
##########
@@ -251,6 +321,56 @@ fn is_epoch(part: &str) -> bool {
matches!(part.to_lowercase().as_str(), "epoch")
}
+fn date_to_scalar(date: NaiveDate, target_type: &DataType) ->
Option<ScalarValue> {
+ let days = date
+ .signed_duration_since(NaiveDate::from_epoch_days(0)?)
+ .num_days();
+
+ Some(match target_type {
+ Date32 => ScalarValue::Date32(Some(days as i32)),
+ Date64 => ScalarValue::Date64(Some(days * MILLISECONDS_IN_DAY)),
+
+ Timestamp(unit, tz_opt) => {
Review Comment:
Fixed date32/64
https://github.com/apache/datafusion/pull/19733/commits/62b08410032b5fe45d49e9e602c1253e4121bf7c
As for timestamp: [dyn
TimestampType::make_value()](https://docs.rs/arrow/latest/arrow/datatypes/trait.ArrowTimestampType.html#tymethod.make_value)
is using a `NaiveDate`, not `DateTime<Tz>`. We'd still have to do some tz math
to create an offset for `NaiveDate`. (if only there was an existing API to
help...)
--
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]