Skip to content

Commit 3097190

Browse files
TST: Test non-nanosecond datetimes in PyArrow Parquet dataframes (#59393)
* Add test_non_nanosecond_timestamps * Fix lint errors * Remove detailed comment; use temp path helper * Use temp_file * Apply suggestions from code review Co-authored-by: Matthew Roeschke <[email protected]> * Remove extra empty line * Skip test in minimal version env --------- Co-authored-by: Matthew Roeschke <[email protected]>
1 parent eac20cc commit 3097190

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pandas/tests/io/test_parquet.py

+15
Original file line numberDiff line numberDiff line change
@@ -1137,6 +1137,21 @@ def test_infer_string_large_string_type(self, tmp_path, pa):
11371137
# assert result["strings"].dtype == "string"
11381138
# FIXME: don't leave commented-out
11391139

1140+
def test_non_nanosecond_timestamps(self, temp_file):
1141+
# GH#49236
1142+
pa = pytest.importorskip("pyarrow", "11.0.0")
1143+
pq = pytest.importorskip("pyarrow.parquet")
1144+
1145+
arr = pa.array([datetime.datetime(1600, 1, 1)], type=pa.timestamp("us"))
1146+
table = pa.table([arr], names=["timestamp"])
1147+
pq.write_table(table, temp_file)
1148+
result = read_parquet(temp_file)
1149+
expected = pd.DataFrame(
1150+
data={"timestamp": [datetime.datetime(1600, 1, 1)]},
1151+
dtype="datetime64[us]",
1152+
)
1153+
tm.assert_frame_equal(result, expected)
1154+
11401155

11411156
class TestParquetFastParquet(Base):
11421157
@pytest.mark.xfail(reason="datetime_with_nat gets incorrect values")

0 commit comments

Comments
 (0)