← Back to Pull requests

GH-54958: [Format] Add custom_metadata to DictionaryEncoding for the dictionary value type #54959

Open
unknown opened this pull request with 432 lines diff across 5 files
View on GitHub
unknown unknown commented on Oct 22, 2026 16:56 UTC
Author

Rationale for this change


This PR was split out of #53994 at review request, so that the specification change can be reviewed on its own.

In IPC, a dictionary-encoded column is a single Field whose type is the value type. The only metadata slot was Field.custom_metadata, so dictionary<values=extension<X>> and extension<X, storage=dictionary<...>> serialized identically. Arrow C++ reads both as the latter, so pyarrow cannot read back its own stream of pa.dictionary(pa.int32(), pa.uuid()). The dev@ thread (https://lists.apache.org/thread/4xj0yrl2vn0lbrv39p3dvd28okvkjxyz) reached lazy consensus on adding KeyValue metadata for the value type to DictionaryEncoding (option 1).

This is a format change, so it needs a [VOTE] on dev@ and two reference implementations (see below).

What changes are included in this PR?


  • format/Schema.fbs: an optional custom_metadata: [KeyValue] appended to DictionaryEncoding. It is the custom_metadata of the dictionary value type, with the same semantics as Field.custom_metadata (including the reserved ARROW:extension: keys) but applied to the dictionary values. It is the IPC counterpart of ArrowSchema.dictionary->metadata in the C Data Interface.

  • Columnar.rst: a new "Dictionary-encoded extension types" section. The format version is bumped to 1.6.

  • - Writers should put a value extension type's ARROW:extension:name/ARROW:extension:metadata there rather than in Field.custom_metadata.
    - Readers apply it to the value type before wrapping it in the dictionary type, then apply Field.custom_metadata as before.
    - Extension types whose storage type is a dictionary keep using Field.custom_metadata, as today.
  • Versioning.rst: the version 1.6 entry.

  • CDataInterface.rst: a note that ArrowSchema.dictionary->metadata holds the metadata of the dictionary value type, and how it maps to the two IPC custom_metadata slots.

  • Integration.rst: a matching optional "metadata" member in the "dictionary" object of the integration JSON format, with an example.
  • The member is appended, so it is backward compatible. MetadataVersion stays V5, and the file footer and Flight need no other change. Readers that predate it ignore it and read a dictionary of the storage type.

    Generated flatbuffers code is not included. Each implementation regenerates its bindings in its own PR.

    Are these changes tested?


    This PR changes only the specification. It is exercised by the implementations and a new dictionary_extension archery integration case:
  • C++: #53994, stacked on this PR

  • Go, the second reference implementation: apache/arrow-go#1381. C++ ⇄ Go passes the new case over IPC.

  • Rust, which reads the new member: apache/arrow-rs#11622

  • nanoarrow, which maps the member to ArrowSchema.dictionary->metadata: apache/arrow-nanoarrow#972
  • Are there any user-facing changes?


    Yes, this is a format addition (version 1.6). Writers that adopt it move a dictionary value type's extension keys from Field.custom_metadata to DictionaryEncoding.custom_metadata. Readers that predate it read such columns as a plain dictionary of the storage type and lose the extension type.

    Was AI used for this PR?


    PR code and description written by:
  • Human

  • AI
  • Reviewed before submission by:

  • Human

  • AI

  • Not reviewed
  • GitHub Issue: #54958

    🤖 Generated with Claude Code

    Diff: 432 lines (+324 / -108) across 5 files Reviewer: rustyconover Review duration: 56102m
    All Vouch review confidence checks passed
    Residual risk 0.29 = Change Risk (0.52) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 432 lines diff across 5 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.363
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #54959"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52.2% (MEDIUM) · Higher = larger blast radius
    52.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.7% · Lower = rushed or shallow review
    44.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 28.8% · Safe to merge
    28.8%
    Repository