(
&self,
v: &ScalarValue,
tz: &Option<Arc<str>>,
)
| 1162 | } |
| 1163 | |
| 1164 | fn handle_timestamp<T: ArrowTemporalType>( |
| 1165 | &self, |
| 1166 | v: &ScalarValue, |
| 1167 | tz: &Option<Arc<str>>, |
| 1168 | ) -> Result<ast::Expr> |
| 1169 | where |
| 1170 | i64: From<T::Native>, |
| 1171 | { |
| 1172 | let time_unit = match T::DATA_TYPE { |
| 1173 | DataType::Timestamp(unit, _) => unit, |
| 1174 | _ => { |
| 1175 | return Err(internal_datafusion_err!( |
| 1176 | "Expected Timestamp, got {:?}", |
| 1177 | T::DATA_TYPE |
| 1178 | )); |
| 1179 | } |
| 1180 | }; |
| 1181 | |
| 1182 | let ts = if let Some(tz) = tz { |
| 1183 | let dt = v |
| 1184 | .to_array()? |
| 1185 | .as_any() |
| 1186 | .downcast_ref::<PrimitiveArray<T>>() |
| 1187 | .ok_or(internal_datafusion_err!( |
| 1188 | "Failed to downcast type {v:?} to arrow array" |
| 1189 | ))? |
| 1190 | .value_as_datetime_with_tz(0, tz.parse()?) |
| 1191 | .ok_or(internal_datafusion_err!( |
| 1192 | "Unable to convert {v:?} to DateTime" |
| 1193 | ))?; |
| 1194 | self.dialect.timestamp_with_tz_to_string(dt, time_unit) |
| 1195 | } else { |
| 1196 | v.to_array()? |
| 1197 | .as_any() |
| 1198 | .downcast_ref::<PrimitiveArray<T>>() |
| 1199 | .ok_or(internal_datafusion_err!( |
| 1200 | "Failed to downcast type {v:?} to arrow array" |
| 1201 | ))? |
| 1202 | .value_as_datetime(0) |
| 1203 | .ok_or(internal_datafusion_err!( |
| 1204 | "Unable to convert {v:?} to DateTime" |
| 1205 | ))? |
| 1206 | .to_string() |
| 1207 | }; |
| 1208 | |
| 1209 | Ok(ast::Expr::Cast { |
| 1210 | kind: ast::CastKind::Cast, |
| 1211 | expr: Box::new(ast::Expr::value(SingleQuotedString(ts))), |
| 1212 | data_type: self.dialect.timestamp_cast_dtype(&time_unit, &None), |
| 1213 | array: false, |
| 1214 | format: None, |
| 1215 | }) |
| 1216 | } |
| 1217 | |
| 1218 | fn handle_time<T: ArrowTemporalType>(&self, v: &ScalarValue) -> Result<ast::Expr> |
| 1219 | where |
nothing calls this directly
no test coverage detected