Skip to content

test: assert dictionary page is listed first in page_encoding_stats - #10051

Closed
alamb wants to merge 1 commit into
apache:mainfrom
alamb:alamb/test-dict-page-encoding-stats-order
Closed

alamb wants to merge 1 commit into
apache:mainfrom
alamb:alamb/test-dict-page-encoding-stats-order

Conversation

@alamb

@alamb alamb commented Jun 2, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

While reviewing #10020 I (claude) noticed that the deferred-dictionary-ordering change makes the ArrowWriter emit data pages before the dictionary page, which reorders the page_encoding_stats list so the DICTIONARY_PAGE entry lands last instead of first.

There is currently no test asserting the order of page_encoding_stats, so that change is silent. This PR adds one.

It passes on main and is intended to fail against the #10020 branch, documenting the dictionary-first ordering as an explicit invariant so any future reordering is caught.

What changes are included in this PR?

A single new unit test, dictionary_page_encoding_stats_lists_dictionary_first, in parquet/src/arrow/arrow_writer/mod.rs. No production code changes.

Are these changes tested?

The change is a test. Verified it passes on main.

Are there any user-facing changes?

No.

🤖 Generated with Claude Code

Adds a regression test asserting that for a dictionary-encoded column
written via `ArrowWriter`, the `page_encoding_stats` list places the
DICTIONARY_PAGE entry before the DATA_PAGE entries, matching the on-disk
dictionary-first page layout and the order produced by the
column-at-a-time `SerializedFileWriter`.

The test reads the full (non-mask) encoding stats via
`ParquetMetaDataOptions::with_encoding_stats_as_mask(false)`, since the
default metadata reader collapses the list to a bitmask and discards the
ordering under test.

This passes on `main` and is intended to guard the dictionary-first
ordering of the emitted metadata.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@github-actions github-actions Bot added the parquet parquet crate label Jun 2, 2026
@alamb alamb closed this Jun 2, 2026
@alamb alamb reopened this Jun 2, 2026
@alamb alamb closed this Jun 2, 2026
@alamb

alamb commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

I am not convinced it si important that the stats remain in the same order

ump45nose pushed a commit to ump45nose/arrow-rs that referenced this pull request Oct 18, 2026
…e#11682)

# Which issue does this PR close?

- Closes apache#11659

# Rationale for this change

Since 59.0.0, `ArrowWriter` writes the dictionary page's
`encoding_stats` entry after the data page entries. The file layout did
not change: the dictionary page is still written first. Arrow C++
([`IsColumnChunkFullyDictionaryEncoded`](https://github.com/apache/arrow/blob/9f0341314ca96eb58081d4132c77b460d880b2b0/cpp/src/parquet/file_reader.cc#L63-L88))
requires `encoding_stats[0]` to be the dictionary page. With the 59.x
order, Arrow C++ does not see any parquet-rs column chunk as fully
dictionary encoded, so it cannot use its dictionary fast path.

| | `encoding_stats` (file order) |
|---|---|
| before this PR | `DATA_PAGE RLE_DICTIONARY`, `DICTIONARY_PAGE PLAIN` |
| after this PR (and 58.x) | `DICTIONARY_PAGE PLAIN`, `DATA_PAGE
RLE_DICTIONARY` |

The new order was not a design goal of
apache#10020. It was a side effect: the
deferred-ordering page writer gets the dictionary page last, and the
stats were recorded in the order the pages were produced. Review
accepted this because the spec defines the list as a set
(apache#10051 was closed for that
reason). But a known reader depends on the order, and restoring it
changes only metadata, so the change has no memory or throughput cost.

# What changes are included in this PR?

`GenericColumnWriter::write_dictionary_page` now inserts the dictionary
entry at the front of `encoding_stats` instead of appending it. The
dictionary page is always laid out first, on both the deferred (Arrow)
path and the `SerializedFileWriter` path, so the stats now follow file
order. On the non-deferred path the list is still empty when the
dictionary is written, so its output does not change. When the writer
falls back from dictionary to plain encoding, the result is `DICTIONARY,
RLE_DICTIONARY data, PLAIN data`, which also matches the file layout.

# Are these changes tested?

Yes. The new `dictionary_page_encoding_stats_lists_dictionary_first`
test (adapted from apache#10051) checks
that `stats[0]` is the dictionary page. It fails on `main` and passes
with this change. The existing column writer and arrow writer tests
pass.

# Are there any user-facing changes?

Only the order of `page_encoding_stats` in files written by
`ArrowWriter`. It goes back to the order used before 59.0.0.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parquet parquet crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant