Repository navigation
Add custom_metadata to IPC DictionaryEncoding - #11622
Draft
rustyconover wants to merge 1 commit into
Draft
rustyconover wants to merge 1 commit into
rustyconover wants to merge 1 commit into
Conversation
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>
3 of 5 tasks
This was referenced Oct 16, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
In Arrow IPC, a dictionary whose values are an extension type and an extension type whose storage is a dictionary serialize identically, because
Field.custom_metadatais the only metadata slot. apache/arrow#49704 adds an optionalcustom_metadata: [KeyValue]member toDictionaryEncodingholding metadata for the dictionary value type. That change has lazy consensus on dev@arrow, targets format version 1.6, and is drafted in apache/arrow#53994, with a Go implementation in apache/arrow-go#1381 and a nanoarrow implementation in apache/arrow-nanoarrow#972. arrow-rs needs to read schemas that use it.This PR is a draft until the format change is voted on in apache/arrow.
What changes are included in this PR?
format/Schema.fbsgainsDictionaryEncoding.custom_metadataand the version 1.6 history line.arrow-ipc/src/gen/Schema.rsis regenerated; only theDictionaryEncodingadditions change.DataType::Dictionarycannot carry metadata for its value type (Field metadata for dictionary-encoded extension types is lost #7982). Until it can, the reader copies the value type metadata into theField's metadata when the field has noARROW:extension:nameof its own; keys already in the field metadata win. Otherwise the value metadata is dropped. This keeps today's behaviour for arrow-rs users, who see e.g.arrow.uuidon dictionary fields, and that metadata survives read-then-write. The mapping is documented in thearrow_ipc::readermodule docs and on the schema conversion functions.field_from_jsonvalidates the optional"dictionary"."metadata"attribute and maps it the same way, so the JSON and IPC readings of an integration file agree.Field::try_from(&FFI_ArrowSchema)maps the metadata of an imported dictionary schema'sdictionary(its value type) the same way, so the IPC, integration JSON and C Data readers agree. The C Data export is unchanged.Field.custom_metadata, the pre-1.6 position.Are these changes tested?
Yes. Unit tests build schema flatbuffers containing the new member with the generated builders. They cover:
StreamReaderand through theFileReaderfooter.Integration JSON tests cover the same mapping and the validation errors, and C Data import tests cover the mapping, including nesting in list and struct. With the C++ and Go drafts, archery reads their
dictionary_extensionoutput correctly in arrow-rs, over IPC and C Data.Are there any significant user-facing changes?
Fieldmetadata as described above. This applies to the arrow-ipc readers and to the arrow-schema C Data import (Field::try_from(&FFI_ArrowSchema)), which previously dropped the metadata of an imported schema'sdictionary. Malformed metadata on thatdictionaryis now an import error.DictionaryEncoding.custom_metadataare valid UTF-8. A schema with non-UTF-8 bytes there, which Arrow C++ accepts, is now rejected; previously the member was ignored as an unknown field.arrow_ipc::DictionaryEncodingArgsgains a public field,custom_metadata. Code that builds it with a struct literal must add the field or use..Default::default(). This needs theapi-changelabel.The code and this description were written by AI (Claude Code). The generated flatbuffers code was verified byte-identical against flatc 25.2.10 output, and the change was reviewed by a human maintainer and an AI reviewer.
🤖 Generated with Claude Code