Skip to content

Commit d4ed023

Browse files
committed
fix
1 parent 2559ca0 commit d4ed023

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

native/spark-expr/src/utils.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,11 @@ pub fn array_with_timezone(
7676
assert!(!timezone.is_empty());
7777
match to_type {
7878
Some(DataType::Utf8) | Some(DataType::Date32) => Ok(array),
79-
// Pass through for Timestamp(_, Some(_)) targets: the cast_array dispatch arm
80-
// handles NTZ → TIMESTAMP conversion with correct "UTC" output annotation.
81-
Some(DataType::Timestamp(_, Some(_))) => Ok(array),
79+
Some(DataType::Timestamp(_, Some(target_tz))) => {
80+
// Interpret NTZ as local time in session TZ; annotate output with target TZ
81+
// so the result has the exact annotation the caller expects.
82+
timestamp_ntz_to_timestamp(array, timezone.as_str(), Some(target_tz.as_ref()))
83+
}
8284
Some(DataType::Timestamp(TimeUnit::Microsecond, None)) => {
8385
// Convert from Timestamp(Millisecond, None) to Timestamp(Microsecond, None)
8486
let millis_array = as_primitive_array::<TimestampMillisecondType>(&array);
@@ -100,9 +102,9 @@ pub fn array_with_timezone(
100102
assert!(!timezone.is_empty());
101103
match to_type {
102104
Some(DataType::Utf8) | Some(DataType::Date32) => Ok(array),
103-
// Pass through for Timestamp(_, Some(_)) targets: the cast_array dispatch arm
104-
// handles NTZ → TIMESTAMP conversion with correct "UTC" output annotation.
105-
Some(DataType::Timestamp(_, Some(_))) => Ok(array),
105+
Some(DataType::Timestamp(_, Some(target_tz))) => {
106+
timestamp_ntz_to_timestamp(array, timezone.as_str(), Some(target_tz.as_ref()))
107+
}
106108
_ => {
107109
// Not supported
108110
Err(ArrowError::CastError(format!(
@@ -117,9 +119,9 @@ pub fn array_with_timezone(
117119
assert!(!timezone.is_empty());
118120
match to_type {
119121
Some(DataType::Utf8) | Some(DataType::Date32) => Ok(array),
120-
// Pass through for Timestamp(_, Some(_)) targets: the cast_array dispatch arm
121-
// handles NTZ → TIMESTAMP conversion with correct "UTC" output annotation.
122-
Some(DataType::Timestamp(_, Some(_))) => Ok(array),
122+
Some(DataType::Timestamp(_, Some(target_tz))) => {
123+
timestamp_ntz_to_timestamp(array, timezone.as_str(), Some(target_tz.as_ref()))
124+
}
123125
_ => {
124126
// Not supported
125127
Err(ArrowError::CastError(format!(

0 commit comments

Comments
 (0)