|
16 | 16 | // under the License. |
17 | 17 |
|
18 | 18 | use crate::execution::operators::ExecutionError; |
19 | | -use arrow::array::{new_null_array, DictionaryArray, StructArray}; |
20 | | -use arrow::datatypes::DataType; |
21 | 19 | use arrow::{ |
22 | | - array::{cast::AsArray, types::Int32Type, Array, ArrayRef}, |
| 20 | + array::{ |
| 21 | + cast::AsArray, new_null_array, types::Int32Type, types::TimestampMicrosecondType, Array, |
| 22 | + ArrayRef, DictionaryArray, StructArray, |
| 23 | + }, |
23 | 24 | compute::{cast_with_options, take, CastOptions}, |
| 25 | + datatypes::{DataType, TimeUnit}, |
24 | 26 | util::display::FormatOptions, |
25 | 27 | }; |
26 | 28 | use datafusion::common::{Result as DataFusionResult, ScalarValue}; |
27 | 29 | use datafusion::execution::object_store::ObjectStoreUrl; |
28 | 30 | use datafusion::execution::runtime_env::RuntimeEnv; |
29 | 31 | use datafusion::physical_plan::ColumnarValue; |
30 | | -use datafusion_comet_spark_expr::utils::array_with_timezone; |
31 | 32 | use datafusion_comet_spark_expr::EvalMode; |
32 | 33 | use object_store::path::Path; |
33 | 34 | use object_store::{parse_url, ObjectStore}; |
@@ -128,10 +129,6 @@ fn cast_array( |
128 | 129 | parquet_options: &SparkParquetOptions, |
129 | 130 | ) -> DataFusionResult<ArrayRef> { |
130 | 131 | use DataType::*; |
131 | | - let array = match to_type { |
132 | | - Timestamp(_, None) => array, // array_with_timezone does not support to_type of NTZ. |
133 | | - _ => array_with_timezone(array, parquet_options.timezone.clone(), Some(to_type))?, |
134 | | - }; |
135 | 132 | let from_type = array.data_type().clone(); |
136 | 133 |
|
137 | 134 | let array = match &from_type { |
@@ -166,6 +163,14 @@ fn cast_array( |
166 | 163 | to_type, |
167 | 164 | parquet_options, |
168 | 165 | )?), |
| 166 | + (Timestamp(TimeUnit::Microsecond, None), Timestamp(TimeUnit::Microsecond, Some(tz))) => { |
| 167 | + Ok(Arc::new( |
| 168 | + array |
| 169 | + .as_primitive::<TimestampMicrosecondType>() |
| 170 | + .reinterpret_cast::<TimestampMicrosecondType>() |
| 171 | + .with_timezone(Arc::clone(tz)), |
| 172 | + )) |
| 173 | + } |
169 | 174 | _ => Ok(cast_with_options(&array, to_type, &PARQUET_OPTIONS)?), |
170 | 175 | } |
171 | 176 | } |
|
0 commit comments