alamb commented on code in PR #11454:
URL: https://github.com/apache/datafusion/pull/11454#discussion_r1680103048


##########
datafusion/expr/src/columnar_value.rs:
##########
@@ -195,19 +195,39 @@ impl ColumnarValue {
                 kernels::cast::cast_with_options(array, cast_type, 
&cast_options)?,
             )),
             ColumnarValue::Scalar(scalar) => {
-                let scalar_array =
-                    if cast_type == &DataType::Timestamp(TimeUnit::Nanosecond, 
None) {
-                        if let ScalarValue::Float64(Some(float_ts)) = scalar {
-                            ScalarValue::Int64(Some(
-                                (float_ts * 1_000_000_000_f64).trunc() as i64,
-                            ))
-                            .to_array()?
-                        } else {
-                            scalar.to_array()?
-                        }
+                let scalar_array = if cast_type
+                    == &DataType::Timestamp(TimeUnit::Nanosecond, None)
+                {
+                    if let ScalarValue::Float64(Some(float_ts)) = scalar {
+                        ScalarValue::Int64(Some(
+                            (float_ts * 1_000_000_000_f64).trunc() as i64
+                        ))
+                        .to_array()?
                     } else {
                         scalar.to_array()?
-                    };
+                    }
+                } else {
+                    // Arrow by default will parse str as Month for unit 
MonthDayNano.
+                    // So we need to be explict that we want it to parse as 
second.
+                    match (scalar, cast_type) {

Review Comment:
   Yes, eventally the fix should make it up to arrow-cast
   
   In the interim, you could make a wrapper function in datafusion with the 
same signature as `cast` in arrow and implement your logic there for interval 
and fall through to the kernel in arrow-cast otherwise
   
   I haven't though through the implications of changing the semantics of 
casting strings to intervals to be honest



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