Skip to content

feat: support Decimal32 and Decimal64 columns on data storage version 2.3 - #11594

Draft
LuciferYang wants to merge 3 commits into
lance-format:mainfrom
LuciferYang:feat/decimal32-64
Draft

LuciferYang wants to merge 3 commits into
lance-format:mainfrom
LuciferYang:feat/decimal32-64

Conversation

@LuciferYang

Copy link
Copy Markdown
Contributor

Implements #5174 on top of the spec in #11593: Arrow Decimal32 and Decimal64 columns are stored on data storage version 2.3 and rejected on earlier versions. Draft until the spec lands; the write-up follows once CI reports.

🤖 Generated with Claude Code

@github-actions github-actions Bot added A-python Python bindings A-encoding Encoding, IO, file reader/writer A-docs Documentation enhancement New feature or request labels Nov 28, 2026
Xuanwo pushed a commit that referenced this pull request Nov 30, 2026
….3 (#11593)

Adds two logical types to the table schema spec, `decimal:32:P:S` for
Arrow `Decimal32` and `decimal:64:P:S` for Arrow `Decimal64`. This is
the spec half of #5174 and follows wjones127's proposal in #5818; the
standalone-file gate, the flag and the scale rules came out of Xuanwo's
review here. The implementation is #11594.

Released Lance versions parse only `decimal:128` and `decimal:256`
("Only Decimal128 and Decimal256 is supported"). So, for a field of
either type at any nesting depth, including inside a `fixed_size_list`:

- A Lance file, index files included, must use file version 2.3 or
later.
- A table must have data storage version
(`Manifest.data_format.version`) 2.3 or later and set the new feature
flag `FLAG_DECIMAL32_AND_DECIMAL64` (`2^23`) in both
`reader_feature_flags` and `writer_feature_flags`. Every commit whose
schema has such a field sets both bits, and dropping the field,
overwriting, restoring or cloning does not clear them.
- Readers reject as invalid a file below 2.3 that has such a field, and
a manifest that has one with a data storage version below 2.3 or without
both bits.

The flag keeps out older clients that enforce feature flags. In Xuanwo's
review, 14.0.3 and 16.0.0-beta.5 failed to scan a table with these types
and no flag, even when projecting only other columns, and 14.0.3
appended rows that left the new fields null. Both builds refuse any
table with bit 23 set, on read and on write: `FLAG_UNKNOWN` is `1 << 18`
in 14.0.3 and `1 << 23` in 16.0.0-beta.5.

As with bit 22 in #10358, this PR reserves the bit: it adds the constant
and its half-set check, moves `FLAG_UNKNOWN` to bit 24 and keeps bit 23
unsupported. #11594 turns it on, and I will open a small docs PR marking
it supported once #11594 merges.

Neither type needs a new physical layout: both are fixed-width 32- and
64-bit values that 2.3 already encodes. Precision is 1-9 for `Decimal32`
and 1-18 for `Decimal64`, as in Arrow. These two widths require `0 ≤ S ≤
P`. The existing rule for `decimal:128` and `decimal:256` said `0 ≤ S ≤
P`, although Lance accepts a negative scale for them; this PR changes it
to `-128 ≤ S ≤ P`.

#10431 and #10459 also claim bit 23. Whichever of the three merges first
keeps it. The others move to a free bit everywhere they use 23 (spec and
protos, plus any constant, `FLAG_UNKNOWN` and implementation) and have
their approvals re-confirmed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

A-docs Documentation A-encoding Encoding, IO, file reader/writer A-python Python bindings enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant