neilconway commented on code in PR #20224:
URL: https://github.com/apache/datafusion/pull/20224#discussion_r2784224849


##########
datafusion/functions/src/datetime/to_timestamp.rs:
##########
@@ -430,27 +430,56 @@ impl ScalarUDFImpl for ToTimestampFunc {
                 .cast_to(&Timestamp(Second, None), None)?
                 .cast_to(&Timestamp(Nanosecond, tz), None),
             Null | Timestamp(_, _) => args[0].cast_to(&Timestamp(Nanosecond, 
tz), None),
-            Float16 => {
-                let arr = args[0].to_array(1)?;
-                let f16_arr = downcast_arg!(&arr, Float16Array);
-                let result: TimestampNanosecondArray =
-                    f16_arr.unary(|x| (x.to_f64() * 1_000_000_000.0) as i64);
-                
Ok(ColumnarValue::Array(Arc::new(result.with_timezone_opt(tz))))
-            }
-            Float32 => {
-                let arr = args[0].to_array(1)?;
-                let f32_arr = downcast_arg!(&arr, Float32Array);
-                let result: TimestampNanosecondArray =
-                    f32_arr.unary(|x| (x as f64 * 1_000_000_000.0) as i64);
-                
Ok(ColumnarValue::Array(Arc::new(result.with_timezone_opt(tz))))
-            }
-            Float64 => {
-                let arr = args[0].to_array(1)?;
-                let f64_arr = downcast_arg!(&arr, Float64Array);
-                let result: TimestampNanosecondArray =
-                    f64_arr.unary(|x| (x * 1_000_000_000.0) as i64);
-                
Ok(ColumnarValue::Array(Arc::new(result.with_timezone_opt(tz))))
-            }
+            Float16 => match &args[0] {
+                ColumnarValue::Scalar(ScalarValue::Float16(value)) => {

Review Comment:
   I believe the current coding is correct -- `value.map()` will map `None` to 
`None`. Lmk if I'm mistaken though.



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