Jefffrey commented on code in PR #19663:
URL: https://github.com/apache/datafusion/pull/19663#discussion_r2674652479


##########
datafusion/functions/src/datetime/to_timestamp.rs:
##########
@@ -380,13 +451,14 @@ impl ScalarUDFImpl for ToTimestampFunc {
         let tz = self.timezone.clone();
 
         match args[0].data_type() {
-            Int32 | Int64 => args[0]
+            Int8 | Int16 | Int32 | Int64 | UInt8 | UInt16 | UInt32 | UInt64 => 
args[0]
                 .cast_to(&Timestamp(Second, None), None)?
                 .cast_to(&Timestamp(Nanosecond, tz), None),
             Null | Timestamp(_, _) => args[0].cast_to(&Timestamp(Nanosecond, 
tz), None),
-            Float64 => {
+            Float16 | Float32 | Float64 => {
+                let arg = args[0].cast_to(&Float64, None)?;

Review Comment:
   > Float16 still needs to be cast to Float64
   
   Could you elaborate on this?
   
   I was mainly hoping to eliminate unnecessary casts where possible since they 
technically allocate new arrays



##########
datafusion/functions/src/datetime/to_timestamp.rs:
##########
@@ -325,6 +327,75 @@ impl_to_timestamp_constructors!(ToTimestampMillisFunc);
 impl_to_timestamp_constructors!(ToTimestampMicrosFunc);
 impl_to_timestamp_constructors!(ToTimestampNanosFunc);
 
+fn decimal_to_nanoseconds(value: i128, scale: i8) -> i64 {
+    let nanos_exponent = 9_i16 - scale as i16;
+    let timestamp_nanos = if nanos_exponent >= 0 {
+        value * 10_i128.pow(nanos_exponent as u32)
+    } else {
+        value / 10_i128.pow(nanos_exponent.unsigned_abs() as u32)
+    };
+    timestamp_nanos as i64
+}
+
+fn decimal128_to_timestamp_nanos(

Review Comment:
   I notice for decimal256 we try to get the i128 value; is there any edge case 
if it doesn't fit in an i128, or is it not a concern as that value would be too 
large for timestamp output anyway?



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