alamb commented on code in PR #11454: URL: https://github.com/apache/datafusion/pull/11454#discussion_r1678281210
########## 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: one issue with this approach is that it will only work for single values like `'1'::interval` the behavior of ```sql create table foo as values ('1'); select column1::interval from foo; ``` will not be affected I recommend you update the code in `kernels::cast` to have the new semantics you have in mind -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org