Skip to content

Commit cef87e4

Browse files
kevinjqliuFokko
andauthored
Support transforms with datetime timezones (#1086)
## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123. --> - Closes #1078. ## What changes are included in this PR? <!-- Provide a summary of the modifications in this PR. List the main changes such as new features, bug fixes, refactoring, or any other updates. --> Enable `chrono-tz` feature in the `arrow` dependency Thanks to this reference, delta-io/delta-rs#2295 ## Are these changes tested? <!-- Specify what test covers (unit test, integration test, etc.). If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> Yes. Unit test coverage using datetime with timezone Co-authored-by: Fokko Driesprong <[email protected]>
1 parent 75c5f34 commit cef87e4

File tree

3 files changed

+117
-2
lines changed

3 files changed

+117
-2
lines changed

bindings/python/Cargo.lock

+103
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindings/python/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ crate-type = ["cdylib"]
3333
[dependencies]
3434
iceberg = { path = "../../crates/iceberg" }
3535
pyo3 = { version = "0.23.3", features = ["extension-module", "abi3-py39"] }
36-
arrow = { version = "54.1.0", features = ["pyarrow"] }
36+
arrow = { version = "54.1.0", features = ["pyarrow", "chrono-tz"] }

bindings/python/tests/test_transform.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
from datetime import date, datetime
18+
from datetime import date, datetime, timezone
1919

2020
import pyarrow as pa
2121
import pytest
@@ -63,6 +63,18 @@ def test_year_transform():
6363
assert result == expected
6464

6565

66+
def test_year_transform_with_tz():
67+
arr = pa.array(
68+
[
69+
datetime(1970, 1, 1, 0, 0, 0, tzinfo=timezone.utc),
70+
datetime(2000, 1, 1, 0, 0, 0, tzinfo=timezone.utc),
71+
]
72+
)
73+
result = transform.year(arr)
74+
expected = pa.array([0, 30], type=pa.int32())
75+
assert result == expected
76+
77+
6678
def test_month_transform():
6779
arr = pa.array([date(1970, 1, 1), date(2000, 4, 1)])
6880
result = transform.month(arr)

0 commit comments

Comments
 (0)