Skip to content

Commit

Permalink
update arrow (#2762)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Feb 24, 2022
1 parent 43fd1aa commit 330db8d
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion polars/polars-arrow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "Arrow interfaces for Polars DataFrame library"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
arrow = { package = "arrow2", git = "https://github.com/jorgecarleitao/arrow2", rev = "22bf173ec297fbc2ce156bd482cb410b7769073d", default-features = false }
arrow = { package = "arrow2", git = "https://github.com/jorgecarleitao/arrow2", rev = "fb5d4330544d9d746dfc9bdacab5f1f5c1de9203", default-features = false }
# arrow = { package = "arrow2", git = "https://github.com/ritchie46/arrow2", branch = "no_null_propagate_comp", default-features = false }
# arrow = { package = "arrow2", version = "0.9", default-features = false, features = ["compute_concatenate"] }
hashbrown = "0.12"
Expand Down
2 changes: 1 addition & 1 deletion polars/polars-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ unsafe_unwrap = "^0.1.0"
package = "arrow2"
git = "https://github.com/jorgecarleitao/arrow2"
# git = "https://github.com/ritchie46/arrow2"
rev = "22bf173ec297fbc2ce156bd482cb410b7769073d"
rev = "fb5d4330544d9d746dfc9bdacab5f1f5c1de9203"
# branch = "no_null_propagate_comp"
# version = "0.9"
default-features = false
Expand Down
2 changes: 1 addition & 1 deletion polars/polars-io/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private = []
[dependencies]
ahash = "0.7"
anyhow = "1.0"
arrow = { package = "arrow2", git = "https://github.com/jorgecarleitao/arrow2", rev = "22bf173ec297fbc2ce156bd482cb410b7769073d", default-features = false }
arrow = { package = "arrow2", git = "https://github.com/jorgecarleitao/arrow2", rev = "fb5d4330544d9d746dfc9bdacab5f1f5c1de9203", default-features = false }
# arrow = { package = "arrow2", git = "https://github.com/ritchie46/arrow2", branch = "no_null_propagate_comp", default-features = false }
# arrow = { package = "arrow2", version = "0.9", default-features = false }
csv-core = { version = "0.1.10", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion py-polars/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions py-polars/src/arrow_interop/to_py.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use pyo3::prelude::*;

/// Arrow array to Python.
pub(crate) fn to_py_array(array: ArrayRef, py: Python, pyarrow: &PyModule) -> PyResult<PyObject> {
let array_ptr = Box::new(ffi::Ffi_ArrowArray::empty());
let schema_ptr = Box::new(ffi::Ffi_ArrowSchema::empty());
let array_ptr = Box::new(ffi::ArrowArray::empty());
let schema_ptr = Box::new(ffi::ArrowSchema::empty());

let array_ptr = Box::into_raw(array_ptr);
let schema_ptr = Box::into_raw(schema_ptr);
Expand Down
8 changes: 4 additions & 4 deletions py-polars/src/arrow_interop/to_rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ use pyo3::prelude::*;

pub fn array_to_rust(obj: &PyAny) -> PyResult<ArrayRef> {
// prepare a pointer to receive the Array struct
let array = Box::new(ffi::Ffi_ArrowArray::empty());
let schema = Box::new(ffi::Ffi_ArrowSchema::empty());
let array = Box::new(ffi::ArrowArray::empty());
let schema = Box::new(ffi::ArrowSchema::empty());

let array_ptr = &*array as *const ffi::Ffi_ArrowArray;
let schema_ptr = &*schema as *const ffi::Ffi_ArrowSchema;
let array_ptr = &*array as *const ffi::ArrowArray;
let schema_ptr = &*schema as *const ffi::ArrowSchema;

// make the conversion through PyArrow's private API
// this changes the pointer's memory and is thus unsafe. In particular, `_export_to_c` can go out of bounds
Expand Down
17 changes: 17 additions & 0 deletions py-polars/tests/test_datelike.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import io
from datetime import date, datetime, timedelta

import numpy as np
import pandas as pd
import pyarrow as pa
import pytest
from test_series import verify_series_and_expr_api
Expand Down Expand Up @@ -510,3 +512,18 @@ def test_cast_time_units() -> None:
assert dates.dt.cast_time_unit("ms").cast(int).to_list() == list(
dates_in_ns // 1_000_000
)


def test_read_utc_times_parquet() -> None:
df = pd.DataFrame(
data={
"Timestamp": pd.date_range(
"2022-01-01T00:00+00:00", "2022-01-01T10:00+00:00", freq="H"
)
}
)
f = io.BytesIO()
df.to_parquet(f)
f.seek(0)
df_in = pl.read_parquet(f)
assert df_in["Timestamp"][0] == datetime(2022, 1, 1, 0, 0)

0 comments on commit 330db8d

Please sign in to comment.