| 1216 | } |
| 1217 | |
| 1218 | fn handle_time<T: ArrowTemporalType>(&self, v: &ScalarValue) -> Result<ast::Expr> |
| 1219 | where |
| 1220 | i64: From<T::Native>, |
| 1221 | { |
| 1222 | let time = v |
| 1223 | .to_array()? |
| 1224 | .as_any() |
| 1225 | .downcast_ref::<PrimitiveArray<T>>() |
| 1226 | .ok_or(internal_datafusion_err!( |
| 1227 | "Failed to downcast type {v:?} to arrow array" |
| 1228 | ))? |
| 1229 | .value_as_time(0) |
| 1230 | .ok_or(internal_datafusion_err!("Unable to convert {v:?} to Time"))? |
| 1231 | .to_string(); |
| 1232 | Ok(ast::Expr::Cast { |
| 1233 | kind: ast::CastKind::Cast, |
| 1234 | expr: Box::new(ast::Expr::value(SingleQuotedString(time))), |
| 1235 | data_type: ast::DataType::Time(None, TimezoneInfo::None), |
| 1236 | array: false, |
| 1237 | format: None, |
| 1238 | }) |
| 1239 | } |
| 1240 | |
| 1241 | // Explicit type cast on ast::Expr::Value is not needed by underlying engine for certain types |
| 1242 | // For example: CAST(Utf8("binary_value") AS Binary) and CAST(Utf8("dictionary_value") AS Dictionary) |