Skip to content

Inconsistency between written Parquet and Arrow schemas when coerce_timestamps is set #47336

Duplicate

Description

@mhaseeb123

Describe the bug, including details regarding any error messages, version, and platform.

Arrow's parquet writer does not update the unit of timestamp columns in the written base64 encoded ARROW::schema that have been casted using the coerce_timestamps argument. This leads to an inconsistent behavior/confusion when reading such a file as the two schemas (Parquet and ARROW) contain different timestamp units.

Arrow's parquet reader uses the timestamp units from the Parquet schema and only extracts timezone info from the ARROW::schema if available whereas the parquet reader in Polars directly uses the ARROW::schema when available ignoring the Parquet schema

Expected Behavior

The parquet writer may also update the timestamp unit for the casted columns in the ARROW::schema for consistency and/or the parquet reader should override the unit from ARROW::schema over Parquet schema (faithful reconstruction of units + timezone?).

More context

pola-rs/polars#21392 (comment)

Related Issues

pola-rs/polars#21392 and likely pola-rs/polars#23949

Thank you

Component(s)

C++, Parquet

Activity

  1. daviewales commented on Jun 10, 2026

    @daviewales

    Possibly related? #45062

  2. mhaseeb123 commented on Jun 11, 2026

    @mhaseeb123
    Author

    Possibly related? #45062

    Looks like it. Been almost a year since I opened this. I have to remember what the issue even was. 😄

  3. thisisnic commented on Nov 25, 2026

    @thisisnic
    Member

    I used an AI agent to rerun this on current releases and compare it with #45062, and I've reviewed the results.


    🤖 :

    This still happens on pyarrow 26.0.1 (Linux x86_64):

    import base64, datetime
    import pyarrow as pa
    import pyarrow.parquet as pq
    
    t = pa.table({"ts": pa.array([datetime.datetime(2025, 1, 1, 12)], pa.timestamp("ns"))})
    pq.write_table(t, "c.parquet", coerce_timestamps="ms")
    pf = pq.ParquetFile("c.parquet")
    print(pf.schema.column(0).logical_type)  # timeUnit=milliseconds
    raw = pf.metadata.metadata[b"ARROW:schema"]
    print(pa.ipc.read_schema(pa.BufferReader(base64.b64decode(raw))).field("ts").type)  # timestamp[ns]

    The writer builds the Parquet schema with the coercion applied, but serialises the original schema into ARROW:schema (GetSchemaMetadata(schema, ...) in FileWriter::Open, cpp/src/parquet/arrow/writer.cc).

    Polars 2.2.0 reads this file as Datetime(time_unit='ms'), so the mismatch no longer shows up there, but the two schemas in the file still disagree.

    As agreed above this is the same problem as #45062, which is the older report, so closing this one as a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions