alamb commented on a change in pull request #955:
URL: https://github.com/apache/arrow-rs/pull/955#discussion_r752677305
##########
File path: arrow/src/compute/kernels/temporal.rs
##########
@@ -47,23 +47,45 @@ macro_rules! extract_component_from_array {
"Expected format [+-]XX:XX".to_string()
)
} else {
- let fixed_offset = match parse(&mut $parsed, $tz,
StrftimeItems::new("%z")) {
- Ok(_) => match $parsed.to_fixed_offset() {
- Ok(fo) => fo,
- err => return_compute_error_with!("Invalid timezone", err),
- },
- _ => match using_chrono_tz($tz) {
- Some(fo) => fo,
- err => return_compute_error_with!("Unable to parse
timezone", err),
- },
- };
for i in 0..$array.len() {
if $array.is_null(i) {
$builder.append_null()?;
} else {
- match $array.$using(i, fixed_offset) {
- Some(dt) => $builder.append_value(dt.$extract_fn() as
i32)?,
- None => $builder.append_null()?,
+ match $array.value_as_datetime(i) {
+ Some(utc) => {
+ let fixed_offset = match parse(
Review comment:
As written, I think this code will try and parse `$tz` for each row in
the array (even though the `$tz` is a constant).
I wonder if it would be possible to try and parse `$tz` *once* to figure out
if it was fixed (e.g. a `Some<FixedOffset>`, and then only check if that was
`None` for each row before computing `using_chrono_tz_and_utc_naive_date_time`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]