sdf-jkl commented on code in PR #18789:
URL: https://github.com/apache/datafusion/pull/18789#discussion_r2615446862


##########
datafusion/functions/src/datetime/date_part.rs:
##########
@@ -240,6 +269,44 @@ impl ScalarUDFImpl for DatePartFunc {
     }
 }
 
+fn date_to_scalar(date: NaiveDate, target_type: &DataType) -> 
Option<ScalarValue> {
+    let scalar = match target_type {
+        Date32 => {
+            let days = date
+                .signed_duration_since(NaiveDate::from_ymd_opt(1970, 1, 1)?)
+                .num_days() as i32;
+            ScalarValue::Date32(Some(days))
+        }
+        Date64 => {
+            let milis = date
+                .signed_duration_since(NaiveDate::from_ymd_opt(1970, 1, 1)?)
+                .num_milliseconds();
+            ScalarValue::Date64(Some(milis))
+        }
+        Timestamp(unit, tz) => {

Review Comment:
   We're looking to convert from `NaiveDate` to a temporal `ScalarValue`. There 
are no applicable functions, but it's not a big deal.



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