Skip to content

Commit

Permalink
fix: fixed variable naming from tu to time_unit and from tz to time_zone
Browse files Browse the repository at this point in the history
  • Loading branch information
brayanjuls committed Oct 21, 2023
1 parent fa5a0e1 commit 30dcdc3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
16 changes: 10 additions & 6 deletions crates/polars-arrow/src/compute/cast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<i32>(array, tu.to_owned()),
Timestamp(tu, Some(tz)) => {
utf8_to_timestamp_dyn::<i32>(array, tz.clone(), tu.to_owned())
Timestamp(time_unit, None) => {
utf8_to_naive_timestamp_dyn::<i32>(array, time_unit.to_owned())
},
Timestamp(time_unit, Some(time_zone)) => {
utf8_to_timestamp_dyn::<i32>(array, time_zone.clone(), time_unit.to_owned())
},
_ => polars_bail!(InvalidOperation:
"casting from {from_type:?} to {to_type:?} not supported",
Expand All @@ -612,9 +614,11 @@ pub fn cast(
to_type.clone(),
)
.boxed()),
Timestamp(tu, None) => utf8_to_naive_timestamp_dyn::<i64>(array, tu.to_owned()),
Timestamp(tu, Some(tz)) => {
utf8_to_timestamp_dyn::<i64>(array, tz.clone(), tu.to_owned())
Timestamp(time_unit, None) => {
utf8_to_naive_timestamp_dyn::<i64>(array, time_unit.to_owned())
},
Timestamp(time_unit, Some(time_zone)) => {
utf8_to_timestamp_dyn::<i64>(array, time_zone.clone(), time_unit.to_owned())
},
_ => polars_bail!(InvalidOperation:
"casting from {from_type:?} to {to_type:?} not supported",
Expand Down
12 changes: 6 additions & 6 deletions crates/polars-arrow/src/compute/cast/utf8_to.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ pub fn utf8_to_dictionary<O: Offset, K: DictionaryKey>(

pub(super) fn utf8_to_naive_timestamp_dyn<O: Offset>(
from: &dyn Array,
tu: TimeUnit,
time_unit: TimeUnit,
) -> PolarsResult<Box<dyn Array>> {
let from = from.as_any().downcast_ref().unwrap();
Ok(Box::new(utf8_to_naive_timestamp::<O>(from, tu)))
Ok(Box::new(utf8_to_naive_timestamp::<O>(from, time_unit)))
}

/// [`crate::temporal_conversions::utf8_to_timestamp`] applied for RFC3339 formatting
Expand All @@ -129,10 +129,10 @@ pub fn utf8_to_naive_timestamp<O: Offset>(
pub(super) fn utf8_to_timestamp_dyn<O: Offset>(
from: &dyn Array,
timezone: String,
tu: TimeUnit,
time_unit: TimeUnit,
) -> PolarsResult<Box<dyn Array>> {
let from = from.as_any().downcast_ref().unwrap();
utf8_to_timestamp::<O>(from, timezone, tu)
utf8_to_timestamp::<O>(from, timezone, time_unit)
.map(Box::new)
.map(|x| x as Box<dyn Array>)
}
Expand All @@ -141,9 +141,9 @@ pub(super) fn utf8_to_timestamp_dyn<O: Offset>(
pub fn utf8_to_timestamp<O: Offset>(
from: &Utf8Array<O>,
timezone: String,
tu: TimeUnit,
time_unit: TimeUnit,
) -> PolarsResult<PrimitiveArray<i64>> {
utf8_to_timestamp_(from, RFC3339, timezone, tu)
utf8_to_timestamp_(from, RFC3339, timezone, time_unit)
}

/// Conversion of utf8
Expand Down
12 changes: 6 additions & 6 deletions crates/polars-core/src/chunked_array/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
},
};
Expand Down

0 comments on commit 30dcdc3

Please sign in to comment.