Skip to content

Remove primitive map key assertion on record reader - #7769

Closed
njaremko wants to merge 2 commits into
apache:mainfrom
njaremko:nathan_06-24-remove_primitive_map_key_assertion_on_record_reader
Closed

njaremko wants to merge 2 commits into
apache:mainfrom
njaremko:nathan_06-24-remove_primitive_map_key_assertion_on_record_reader

Conversation

@njaremko

@njaremko njaremko commented Jun 24, 2025 •

Copy link
Copy Markdown
Contributor

Note:

This PR has a test that requires a file that needs to be upstreamed

Which issue does this PR close?

Rationale for this change

There's no such requirement in the parquet logical type specification for map types. Spark used to have a similar assertion, that they've since removed

What changes are included in this PR?

Getting rid of the assertion, and adding a test

Are there any user-facing changes?

No

If there are any breaking changes to public APIs, please call them out.

@njaremko njaremko changed the title Nathan 06 24 remove primitive map key assertion on record reader Remove primitive map key assertion on record reader Jun 24, 2025
@njaremko
njaremko force-pushed the nathan_06-24-remove_primitive_map_key_assertion_on_record_reader branch from 2d8b0b9 to ea6d5f6 Compare June 24, 2025 15:56
@github-actions github-actions Bot added the parquet Changes to the parquet crate label Jun 24, 2025
@njaremko
njaremko force-pushed the nathan_06-24-remove_primitive_map_key_assertion_on_record_reader branch from ea6d5f6 to edd9b70 Compare June 24, 2025 15:57

@etseidl etseidl 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 for correcting this oversight @njaremko. FWIW the arrow API handles the test file as expected. Just a few nits with the test.

}

#[test]
fn test_file_reader_rows_nullable1() {

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.

A more descriptive name here would be nice...test_compound_map_key perhaps?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

lol, whoops, yeah, definitely need to fix this


#[test]
fn test_file_reader_rows_nullable1() {
let rows = test_file_reader_rows("databricks.parquet", None).unwrap();

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.

Likewise, something more descriptive than "databricks".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It was named this because it's a file generated by databricks with every supported column type, I'll look into regenerating it

]
),
(
"map_nested".to_string(),

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.

This is the meat of the PR; would it be possible to only have this column in the test file? This is a lot to slog through and obscures the point of the test.

@etseidl etseidl added the bug label Jun 24, 2025
@njaremko

Copy link
Copy Markdown
Contributor Author

I'll update this PR with the requested changes once this gets merged: apache/parquet-testing#87

@alamb

alamb commented Jul 13, 2025

Copy link
Copy Markdown
Contributor

This PR has a test that requires a file that needs to be upstreamed

THanks again @njaremko

Given that we don't really control the timeline of the upstream parquet-testing repo, if you want to unblock this PR you could potentially copy the test file into the arrow-rs repo with a TODO comment that says to change to use the copy upstream in parquet-testing when apache/parquet-testing#87 is merged

@alamb

alamb commented Sep 8, 2025

Copy link
Copy Markdown
Contributor

Marking as draft as I think this PR is no longer waiting on feedback and I am trying to make it easier to find PRs in need of review. Please mark it as ready for review when it is ready for another look

@alamb
alamb marked this pull request as draft September 8, 2025 16:58
@github-actions

Copy link
Copy Markdown

Thank you for your contribution. Unfortunately, this pull request is stale because it has been open 60 days with no activity. Please remove the stale label or comment or this will be closed in 7 days.

@github-actions github-actions Bot added the Stale label Jun 26, 2026
@github-actions github-actions Bot closed this Jul 4, 2026
Jefffrey added a commit to yongster/arrow-rs that referenced this pull request Oct 2, 2026
…#11229)

# Which issue does this PR close?

- Closes apache#7768.

# Rationale for this change

The record API (`RowIter` / `TreeBuilder`) asserted that map keys are
primitive, so reading a file with e.g. struct- or list-keyed maps
panicked. The Parquet spec has no such restriction and the arrow reader
already handles these files.

This picks up the fix from apache#7769 by @njaremko, which went stale waiting
on a test file in apache/parquet-testing#87. Thanks @njaremko for the
original fix.

# What changes are included in this PR?

- Remove the primitive-key assertion in `TreeBuilder::reader_tree`. The
key reader was already built via `reader_tree` in the same way as the
value reader, so no other reader changes are needed.
- `Map` stores entries as `Vec<(Field, Field)>`, so complex keys need no
`Hash`/`Eq`; `Display` and `to_json_value` already handle non-primitive
keys.

# Are these changes tested?

Yes. `test_compound_map_key` writes a file in memory with `ArrowWriter`
containing a map with struct keys and a map with list keys (including an
empty map and an empty-list key), then reads it back with the record API
and checks the rows. Generating the file in the test avoids depending on
apache/parquet-testing#87 and addresses the review feedback on apache#7769
(descriptive test name, only the relevant columns). The test panics
without the fix.

# Are there any user-facing changes?

Files with non-primitive map keys can now be read with the record API
instead of panicking. No API changes.

AI usage: this change was prepared with the help of AI assistants
(Claude, OpenAI models). I reviewed the change and the reader's
key/value level handling, and verified the test fails before and passes
after the fix.

Co-authored-by: Ed Seidl <etseidl@users.noreply.github.com>
Co-authored-by: Jeffrey Vo <jeffrey.vo.australia@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug parquet Changes to the parquet crate Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to parse parquet files with maps with complex keys

3 participants