Skip to content

Tracking Issue: Add Widen encoding for integers and decimals #10733

Open

Description

@connortsui20

This is a tracking issue for adding a Widen encoding for integers and decimals, which stores logical values that can fit in a smaller bit width or precision in a smaller logical dtype.

Status

Integer and decimal Widen execute on the CPU and GPU (#10946, #11303). Its wire format (#11597) and the tightened DecimalByteParts v2 reader (#11596) have merged. Both formats are available in unstable (#11615). Preview and core promotion remain open. DecimalByteParts keeps integer Widen for its narrow MSP. Existing integer paths keep their current representations. Structural and dictionary changes (WD5), internal-child migration (WD6), and the integer Narrow scheme (WR3) are deferred.

Motivation

We have the concept of "narrowing" data in a few places.

  • In the compressor, if we have a Primitive integer array that does not contain very large values, we will call a narrow() method on the primitive array to shrink the logical dtype to fit the values. For example, if my values are all in [-128, 127], but the dtype is I64, then I can narrow this to I8. We use this with list offsets, for example. Note that this changes the dtype of the array.
  • Narrowing can also happen with explicit casts (which are fallible), but this also changes the dtype.
  • In the canonical decimal encoding, there is currently implicit narrowing of the buffer when possible. This is arguably very wrong, see Tracking Issue: Fix Canonical Decimal #10701 for more details.

Ideally, we want a way to keep the logical type of these values while having a better physical encoding that narrows data internally. This is why we want a Widen encoding.

Design

The encoding is named after what decoding does: like FoR is an addition, Widen is a widening cast of its child (see #9156). The compressor scheme that builds it narrows the data, so it keeps the name Narrow.

The Widen encoding will have a single array child that has a narrower logical dtype. For integers, the child has the same signedness and a strictly smaller power-of-two bit width. For decimals, the child has a lower precision whose canonical width is strictly smaller, with the same scale. A positive scale sets a lower bound on that precision. The child always has the same nullability as the parent, and supplies its validity.

For example, a Widen array of I64 can hold an I8 child (if it fits). Or, a Widen array of Decimal(18, 2) (with a 64-bit buffer) can hold a child of Decimal(9, 2) (with a 32-bit buffer).

We can constrain the child of the Widen array such that it must actually shrink the amount of data we need to store. This is only relevant for Decimal: having a Widen(Decimal(17, 2)) with dtype Decimal(18, 2) is completely pointless because it doesn't actually save any space. This is something we might be able to relax in the future, but it seems like a reasonable constraint for now.

Note that the compressor narrowing an internal child does not need to change. This is because list offsets, dictionary codes, run-end ends, patch indices, and other internal children have dtypes that their parent encoding chooses, so a narrow integer dtype there is "correct" by default, and these children technically do not need a Widen. #11459 fixes the logical dtype of the DecimalByteParts most significant part (MSP) from the precision, so narrower MSP storage does need an integer Widen.

Compute

A consequence of making narrowing a physical concern rather than a logical one is that we will need to forward lots of compute into the Widen array's child.

Kernels run on the child at the narrow width and widen only when the result needs it. Any operation without a kernel falls back to canonicalization, which widens the child to the logical dtype.

Compute behavior and remaining work
Operation Behavior on Widen
slice, filter, take, mask, fill_null, zip Run on the child.
compare, between Run on the child. A constant outside the range of the child dtype gives the result without reading the values.
Arithmetic Runs at the smallest width that holds both inputs and the result interval, taken from the non-null bounds. Otherwise it runs at the logical width with checked kernels.
min, max, sum and other aggregates Must preserve the canonical array's results and overflow behavior, including when combining running partials. Ordered aggregates can widen child partials. Decimal Sum pushdown in #11004 uses the logical sum dtype only for the legacy Stat::Sum path. SumV2 and sums without skip_nans keep the fallback.
cast Passes to the child with the same target dtype, since a Widen holds exactly the values of its child.
Generic structural encodings WD5 moves Dict, RunEnd, Sparse, Constant, Masked, Chunked and Interleave above Widen. The earlier plan to merge chunked and interleaved inputs under a top-level Widen is dropped (D25).

The compare shortcut is the reason a decimal child dtype must always come from the values. A buffer width alone does not give a precision (an i32 buffer can hold 2,000,000,000, which needs precision 10), so a child labeled Decimal(9, 2) without a check could hold values above its precision, and the shortcut would return wrong results for them.

Serialization

The first WidenPlugin (#10946) used the separate plugin read and write IDs from #11057 to write a concrete decimal child as vortex.decimal under the parent dtype. #10995 added the reader for noncanonical decimal widths. Those reads scan the valid values because the stored statistics arrive after the plugin returns.

The plugin now reads and writes vortex.widen (#11597). The metadata names the child PType for an integer or the child precision for a decimal. The parent supplies scale and nullability. A concrete decimal child still writes vortex.decimal. Integer and encoded decimal children write vortex.widen, which requires an edition that permits the ID.

Relation to DecimalByteParts v2

Both IDs are available in the experimental unstable edition (#11615). The plan still promotes them together to preview and later to core.

DecimalByteParts owns decimal narrowing. In #11459 the MSP has a logical integer width fixed by the decimal precision, capped at i64. A narrower MSP is an integer Widen, and the existing v1 and v2 wire forms store its child directly. The planned Narrow compressor scheme (WR3) applies to integers.

DecimalByteParts v1 stores values that fit in 64 bits. V2 splits wider values into an MSP and non-nullable u64 lower parts (#11458). The v2 reader now requires lower parts and rejects node buffers (#11596). between and aggregates still decode to canonical form when lower parts exist (#11595). #11615 allowed these paths in unstable. Whether preview waits for faster kernels remains open.

Steps

PR plan (agents keep this list up to date)

The IDs below match the implementation plan. The briefs describe each PR. When a PR opens, add its link. When it merges, tick its box. When its scope changes, add a short note here.

Follow-up issues found while planning:

Unresolved questions

  • Should we store the entire DecimalDType in the Widen metadata, which includes scale? It is kind of pointless because the scale is always the same, but it also doesn't really hurt.
    • No, the metadata stores only the child precision. The scale and nullability of the child always equal those of the parent, so storing them only lets a file hold an invalid child. The format is in no edition yet, so this can still change.
  • Should List and ListView offsets always have an I64 dtype, with Widen providing the narrow physical width? (From the discussion on Epic: Implement Narrow integer encoding #10020.)

Implementation history

Activity

  1. self-assigned this
    on Oct 23, 2026
  2. added
    tracking-issue
    on Oct 23, 2026
  3. changed the title [-]Tracking Issue: Add `Narrow` encoding for integers and decimals[/-] [+]Tracking Issue: Add `Widen` encoding for integers and decimals[/+] on Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

tracking-issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions