diff --git a/crates/polars-arrow/src/compute/cast/mod.rs b/crates/polars-arrow/src/compute/cast/mod.rs index f02daf2a364f..23edbd1c9056 100644 --- a/crates/polars-arrow/src/compute/cast/mod.rs +++ b/crates/polars-arrow/src/compute/cast/mod.rs @@ -585,9 +585,11 @@ pub fn cast( LargeUtf8 => Ok(Box::new(utf8_to_large_utf8( array.as_any().downcast_ref().unwrap(), ))), - Timestamp(tu, None) => utf8_to_naive_timestamp_dyn::(array, tu.to_owned()), - Timestamp(tu, Some(tz)) => { - utf8_to_timestamp_dyn::(array, tz.clone(), tu.to_owned()) + Timestamp(time_unit, None) => { + utf8_to_naive_timestamp_dyn::(array, time_unit.to_owned()) + }, + Timestamp(time_unit, Some(time_zone)) => { + utf8_to_timestamp_dyn::(array, time_zone.clone(), time_unit.to_owned()) }, _ => polars_bail!(InvalidOperation: "casting from {from_type:?} to {to_type:?} not supported", @@ -612,9 +614,11 @@ pub fn cast( to_type.clone(), ) .boxed()), - Timestamp(tu, None) => utf8_to_naive_timestamp_dyn::(array, tu.to_owned()), - Timestamp(tu, Some(tz)) => { - utf8_to_timestamp_dyn::(array, tz.clone(), tu.to_owned()) + Timestamp(time_unit, None) => { + utf8_to_naive_timestamp_dyn::(array, time_unit.to_owned()) + }, + Timestamp(time_unit, Some(time_zone)) => { + utf8_to_timestamp_dyn::(array, time_zone.clone(), time_unit.to_owned()) }, _ => polars_bail!(InvalidOperation: "casting from {from_type:?} to {to_type:?} not supported", diff --git a/crates/polars-arrow/src/compute/cast/utf8_to.rs b/crates/polars-arrow/src/compute/cast/utf8_to.rs index 85a252544e5e..4b6ac51fafd5 100644 --- a/crates/polars-arrow/src/compute/cast/utf8_to.rs +++ b/crates/polars-arrow/src/compute/cast/utf8_to.rs @@ -112,10 +112,10 @@ pub fn utf8_to_dictionary( pub(super) fn utf8_to_naive_timestamp_dyn( from: &dyn Array, - tu: TimeUnit, + time_unit: TimeUnit, ) -> PolarsResult> { let from = from.as_any().downcast_ref().unwrap(); - Ok(Box::new(utf8_to_naive_timestamp::(from, tu))) + Ok(Box::new(utf8_to_naive_timestamp::(from, time_unit))) } /// [`crate::temporal_conversions::utf8_to_timestamp`] applied for RFC3339 formatting @@ -129,10 +129,10 @@ pub fn utf8_to_naive_timestamp( pub(super) fn utf8_to_timestamp_dyn( from: &dyn Array, timezone: String, - tu: TimeUnit, + time_unit: TimeUnit, ) -> PolarsResult> { let from = from.as_any().downcast_ref().unwrap(); - utf8_to_timestamp::(from, timezone, tu) + utf8_to_timestamp::(from, timezone, time_unit) .map(Box::new) .map(|x| x as Box) } @@ -141,9 +141,9 @@ pub(super) fn utf8_to_timestamp_dyn( pub fn utf8_to_timestamp( from: &Utf8Array, timezone: String, - tu: TimeUnit, + time_unit: TimeUnit, ) -> PolarsResult> { - utf8_to_timestamp_(from, RFC3339, timezone, tu) + utf8_to_timestamp_(from, RFC3339, timezone, time_unit) } /// Conversion of utf8 diff --git a/crates/polars-core/src/chunked_array/cast.rs b/crates/polars-core/src/chunked_array/cast.rs index 84976edbb513..2c216a69731a 100644 --- a/crates/polars-core/src/chunked_array/cast.rs +++ b/crates/polars-core/src/chunked_array/cast.rs @@ -203,21 +203,21 @@ impl ChunkCast for Utf8Chunked { Ok(out) }, #[cfg(feature = "dtype-datetime")] - DataType::Datetime(tu, tz) => { - let out = match tz { + DataType::Datetime(time_unit, time_zone) => { + let out = match time_zone { #[cfg(feature = "timezones")] - Some(tz) => { - validate_time_zone(tz)?; + Some(time_zone) => { + validate_time_zone(time_zone)?; let result = cast_chunks( &self.chunks, - &Datetime(tu.to_owned(), Some(tz.clone())), + &Datetime(time_unit.to_owned(), Some(time_zone.clone())), true, )?; Series::try_from((self.name(), result)) }, _ => { let result = - cast_chunks(&self.chunks, &Datetime(tu.to_owned(), None), true)?; + cast_chunks(&self.chunks, &Datetime(time_unit.to_owned(), None), true)?; Series::try_from((self.name(), result)) }, };