Skip to content

Add custom_metadata to IPC DictionaryEncoding - #11622

Open
rustyconover wants to merge 1 commit into
apache:mainfrom
rustyconover:gh-49704-dictionary-value-metadata
Open

rustyconover wants to merge 1 commit into
apache:mainfrom
rustyconover:gh-49704-dictionary-value-metadata

Conversation

@rustyconover

@rustyconover rustyconover commented Oct 16, 2026 •

Copy link
Copy Markdown

Which issue does this PR close?

Rationale for this change

In IPC today, "dictionary of an extension type" and "extension type with dictionary storage" serialize identically, because Field.custom_metadata is the only place metadata can go. The format change in apache/arrow#54959 (see apache/arrow#49704) adds DictionaryEncoding.custom_metadata for the dictionary value type, in format version 1.6. arrow-rs needs to be able to read it.

Merging this should wait for the format change to be accepted in apache/arrow. Implementations for other languages: C++ apache/arrow#53994, Go apache/arrow-go#1381, nanoarrow apache/arrow-nanoarrow#972.

What changes are included in this PR?

  • format/Schema.fbs and the generated arrow-ipc/src/gen/Schema.rs gain the new member (generated code matches flatc 25.2.10).
  • Readers (IPC, integration JSON, and C Data import): DataType::Dictionary can't hold value type metadata yet (Field metadata for dictionary-encoded extension types is lost #7982). Until it can, that metadata is copied onto the Field, unless the field already has its own ARROW:extension:name. Existing field keys win. This keeps today's behavior, where e.g. arrow.uuid shows up on dictionary fields.
  • Writer: unchanged. Dictionary field metadata is still written on the field (the pre-1.6 position).

Are these changes tested?

Yes. Unit tests cover the mapping, key precedence, nesting in list/struct, empty vectors, invalid UTF-8, and reading via StreamReader and FileReader. Integration JSON and C Data import tests cover the same cases. I also checked with archery that arrow-rs reads the C++ and Go dictionary_extension output.

Are there any significant user-facing changes?

  • Value type metadata from 1.6 writers now shows up in Field metadata. C Data import previously dropped it; malformed metadata there is now an error.
  • The flatbuffer verifier rejects non-UTF-8 strings in the new member (C++ accepts them).
  • API change: arrow_ipc::DictionaryEncodingArgs has a new public field, custom_metadata. Struct literals need to add it or use ..Default::default().

Written with help from Claude Code and reviewed by me.

@github-actions github-actions Bot added arrow-ipc arrow-ipc crate arrow-core Core crates related to representing arrow data labels Oct 16, 2026
@rustyconover
rustyconover marked this pull request as ready for review October 21, 2026 15:45
@alamb alamb added the Prolific Author author opened PRs or issues in more than 20 repositories in the last 30 days label Oct 22, 2026
@rustyconover
rustyconover force-pushed the gh-49704-dictionary-value-metadata branch from 3ab2539 to afa15b8 Compare October 26, 2026 15:52
Adds the draft `DictionaryEncoding.custom_metadata` member from
apache/arrow#49704, which holds metadata for the dictionary value type
(for example the extension type of a dictionary whose values are an
extension type), to `format/Schema.fbs` and the generated code
(flatc 25.2.10).

`DataType::Dictionary` cannot carry metadata for its value type
(apache#7982), so until it can the IPC readers copy the value type metadata
into the field's metadata, without replacing keys already present,
unless the field has its own `ARROW:extension:name`, in which case it
is dropped. The integration JSON reader maps the dictionary's optional
`metadata` attribute, and the C Data Interface import maps the metadata
of an imported schema's `dictionary`, the same way, so all three
readers agree. The IPC writer and the C Data export are unchanged:
dictionary field metadata is still written to the field itself.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@rustyconover
rustyconover force-pushed the gh-49704-dictionary-value-metadata branch from afa15b8 to 0ba33b7 Compare October 28, 2026 16:49

This branch has not been deployed

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

Labels

arrow-core Core crates related to representing arrow data arrow-ipc arrow-ipc crate Prolific Author author opened PRs or issues in more than 20 repositories in the last 30 days

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support DictionaryEncoding.custom_metadata (apache/arrow#49704)

2 participants