Skip to content

Commit

Permalink
fix(rust, python): allow +00:00 when loading from arrow (pola-rs#9747)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli authored Jul 11, 2023
1 parent dbe7b51 commit 5b92319
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
5 changes: 3 additions & 2 deletions polars/polars-core/src/series/from.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,9 @@ impl Series {
let mut tz = tz.clone();
if tz.as_deref() == Some("") {
tz = None;
}
if let Some(_tz) = &tz {
} else if tz.as_deref() == Some("+00:00") {
tz = Some("UTC".to_string());
} else if let Some(_tz) = &tz {
#[cfg(feature = "timezones")]
validate_time_zone(_tz)?;
}
Expand Down
Binary file added py-polars/tests/unit/io/files/tz_aware.parquet
Binary file not shown.
12 changes: 12 additions & 0 deletions py-polars/tests/unit/io/test_parquet.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from __future__ import annotations

import io
import os
from datetime import datetime, timezone
from typing import TYPE_CHECKING

import numpy as np
Expand Down Expand Up @@ -507,3 +509,13 @@ def test_parquet_string_cache() -> None:
# so polars should automatically set string cache
f.seek(0)
assert_series_equal(pl.read_parquet(f)["a"].cast(str), df["a"].cast(str))


def test_tz_aware_parquet_9586() -> None:
result = pl.read_parquet(
os.path.join("tests", "unit", "io", "files", "tz_aware.parquet")
)
expected = pl.DataFrame(
{"UTC_DATETIME_ID": [datetime(2023, 6, 26, 14, 15, 0, tzinfo=timezone.utc)]}
).select(pl.col("*").cast(pl.Datetime("ns", "UTC")))
assert_frame_equal(result, expected)

0 comments on commit 5b92319

Please sign in to comment.