Skip to content

[Python][Parquet] RowGroupMetadata.total_byte_size computes wrong uncompressed size #48138

Open

Description

@raulcd

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

The RowGroupMetadata.total_byte_size property is supposed to compute the uncompressed file size:

@property
def total_byte_size(self):
"""Total byte size of all the uncompressed column data in this row group (int)."""
return self.metadata.total_byte_size()

But on a specific file from parquet-testing I've found that is computing the compressed size, see:

>>> import pyarrow.parquet as pq
>>> reader = pq.ParquetFile('../datanomy-extra/raulcd_local/data/02-alltypes_plain.snappy.parquet')
>>> rg = reader.metadata.row_group(0)
>>> rg.total_byte_size
570
>>> sum(rg.column(j).total_compressed_size for j in range(rg.num_columns))
570
>>> sum(rg.column(j).total_uncompressed_size for j in range(rg.num_columns))
532

For a different parquet test file on datanomy is able to compute it correctly, the file is generated here:

@pytest.fixture
def simple_parquet(tmp_path: Path) -> Path:
    """Create a simple test Parquet file with basic types.

    Returns:
        Path to the created Parquet file
    """
    table = pa.table(
        {
            "id": [1, 2, 3, 4, 5],
            "name": ["Alice", "Bob", "Charlie", "David", "Eve"],
            "age": [25, 30, 35, 40, 45],
            "score": [85.5, 90.0, 78.5, 92.0, 88.5],
        }
    )
    file_path = tmp_path / "simple.parquet"
    pq.write_table(table, file_path)
    return file_path

Component(s)

Parquet, Python

Activity

  1. thisisnic commented on Nov 26, 2026

    @thisisnic
    Member

    I used an AI agent to investigate this while going through older bug issues, and I've reviewed the results. @raulcd does this sound right to you?


    🤖 :

    total_byte_size isn't computed on read: the reader returns the value stored in the row group metadata (cpp/src/parquet/metadata.cc). Decoding the footer of alltypes_plain.snappy.parquet with a generic Thrift library gives the same 570, so that is what the file contains.

    What differs is what the writer stored. That file was written by impala version 1.3.0-INTERNAL, which stored the compressed size. Arrow C++ did the same until PARQUET-2008 (#9791, in 4.0.0):

    written by total_byte_size sum of compressed sum of uncompressed
    Impala 1.3.0 (alltypes_plain.snappy.parquet) 570 570 532
    pyarrow 3.0.0 148538 148538 266376
    pyarrow 4.0.0, same table 266376 148538 266376

    pyarrow 22.0.0 and 26.0.1 read the same values from all three.

    So this looks like a property of files from older writers rather than a reader bug, and summing the columns' total_uncompressed_size, as datanomy now does, is the reliable approach. If that's right, this could become a docs issue: a note in the RowGroupMetaData.total_byte_size docstring that the value is whatever the writer stored.

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