Skip to content

feat(arrow-schema): add fixed and variable closedness range canonical extension types - #11371

Draft
Hoeze wants to merge 2 commits into
apache:mainfrom
Hoeze:feat/arrow-range-extension
Draft

Hoeze wants to merge 2 commits into
apache:mainfrom
Hoeze:feat/arrow-range-extension

Conversation

@Hoeze

@Hoeze Hoeze commented Oct 4, 2026

Copy link
Copy Markdown

Which issue does this PR close?

Rationale for this change

apache/arrow#50028 proposes two canonical extension types for ranges, i.e.
intervals with a lower and an upper bound over an orderable type T. This PR
adds them to arrow-schema as an independent Rust implementation. The types
only become canonical after the vote on the Arrow dev mailing list, so this PR
should not be merged before the vote passes.

What changes are included in this PR?

  • FixedClosednessRange (arrow.fixed_closedness_range): storage
    Struct<lower: T, upper: T>, metadata
    {"closed": "left" | "right" | "both" | "neither"}.
  • VariableClosednessRange (arrow.variable_closedness_range): storage
    Struct<lower: T, upper: T, lower_inc: Boolean, upper_inc: Boolean>,
    metadata {}.
  • Both are wired into CanonicalExtensionType.

Metadata handling and storage validation follow the C++ implementation:
unknown metadata keys are ignored, and each bound may be nullable or not.

Are these changes tested?

Yes, with unit tests for both types: metadata round trips, and rejection of
invalid metadata and storage types.

Note that I made heavy use of AI to create this PR and copied many structures
from the existing Opaque and tensor extension types. I reviewed each change
and hope the changes I made are meaningful.

Are there any user-facing changes?

Yes, but only additions behind the canonical_extension_types feature.
CanonicalExtensionType is #[non_exhaustive], so the new variants are not
breaking.

@github-actions github-actions Bot added arrow Changes to the arrow crate arrow-schema labels Oct 4, 2026
Hoeze added 2 commits October 4, 2026 12:52
Add the arrow.fixed_closedness_range canonical extension type: a bounded
interval over an orderable type T with a single type-level closedness
("left", "right", "both" or "neither") shared by all values, stored as a
two-field lower/upper struct where a null bound means an unbounded side.
… type

Add the arrow.variable_closedness_range canonical extension type, the
companion of arrow.fixed_closedness_range for ranges that cannot be
canonicalized to a single closedness: each value carries its own
lower_inc/upper_inc inclusivity flags alongside the lower/upper bounds,
mirroring PostgreSQL's internal range representation.
@Hoeze
Hoeze force-pushed the feat/arrow-range-extension branch from 27a52a5 to 5b17b76 Compare October 4, 2026 12:52

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 Changes to the arrow crate arrow-schema

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add fixed and variable closedness range canonical extension types

1 participant