Skip to content

fix: read empty nested Parquet binary dictionaries as null strings - #7808

Open
sunchao wants to merge 4 commits into
apache:mainfrom
sunchao:fix/parquet-all-null-dictionary-field
Open

sunchao wants to merge 4 commits into
apache:mainfrom
sunchao:fix/parquet-all-null-dictionary-field

Conversation

@sunchao

@sunchao sunchao commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Which issue does this PR close?

This isolates the empty dictionary panic reported during review of #7718 for a requested backport to branch-1.2. It covers the nested conversion introduced by #7106 for #7032.

Rationale for this change

A Parquet struct can have a binary dictionary child with null keys and no entries. When reading that child as a string, Comet 1.2.0 calls Arrow's normalized_keys(), which asserts that the dictionary has at least one entry. The read panics even though all the field values are null.

On main, #7718 already avoids the panic by normalizing keys only when expanding the dictionary overflows the string offsets. An empty dictionary cannot overflow. This PR makes the empty case explicit and adds a regression test that can be backported without the other changes in #7718.

What changes are included in this PR?

Return a null string array of the input length when a binary dictionary has no entries. Mark the field present so each parent struct retains its validity. Nonempty dictionaries keep the conversion and overflow handling from #7718.

For the backport, keep the existing dictionary conversion on branch-1.2 and insert the guard before dictionary.normalized_keys(). The test applies unchanged.

How are these changes tested?

nested_all_null_binary_dictionary_reads_as_string writes three present structs with a null Dictionary(Int32, Binary) child and reads them back through the Parquet scan with the child requested as a string. It checks that the three structs are present and all three string fields are null. Hosted CI runs the regression.

@github-actions github-actions Bot added bug Something isn't working area:scan Parquet scan / data reading labels Dec 1, 2026

@comphead comphead left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is in the right place. normalized_keys() is called once in this file (the existing (Dictionary, Utf8) arm), and the new guard returns before it with a null Utf8 array and the leaf marked present. The test reuses the existing struct_batch, struct_schema and roundtrip helpers. A SQL file test cannot replace it because Spark does not write an ARROW:schema dictionary hint, so the Rust test is the right level. new_null_array(&dictionary, 3) produces an empty values child (ArrayData::new_null uses new_empty for dictionary values), which is what the test needs. I did not run it. Its only overlap with another open PR is a trivial test-module conflict in schema_adapter.rs with #7781.

@comphead comphead left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @sunchao, the PR goes into right direction, please check some nits!

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

Labels

area:scan Parquet scan / data reading bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants