Skip to content

feat(format): specify index predicates - #10431

Open
Ali2Arslan wants to merge 6 commits into
lance-format:mainfrom
Ali2Arslan:feat/index-predicates-spec
Open

Ali2Arslan wants to merge 6 commits into
lance-format:mainfrom
Ali2Arslan:feat/index-predicates-spec

Conversation

@Ali2Arslan

@Ali2Arslan Ali2Arslan commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Why

Some queries touch only a subset of rows, such as the embeddings where rejected = true. This PR specifies the persisted format for index predicates, which restrict a scalar or vector index to the rows where a boolean expression is TRUE. It reserves the protobuf field and feature flag ahead of the implementation so voters can review the format contract on its own.

What changed

  • IndexMetadata gains optional IndexPredicate predicate = 15, and table.proto defines IndexPredicate { bytes substrait = 1; repeated int32 fields = 2; }. The expression is a Substrait ExtendedExpression holding one boolean expression whose base schema columns bind by position to top-level field IDs (fields[i]), so column renames do not change the stored predicate. Main uses field 14 for local_fragment_aliases.
  • Reserve FLAG_INDEX_PREDICATES (1 << 24) as a paired reader and writer feature flag in feature_flags.rs and keep it masked out in supported_flags_when until implemented. Main already assigns bit 20 to FLAG_LOCAL_FRAGMENT_ALIASES and bit 21 to FLAG_DELETION_FILE_PATHS. K1 (docs(format): specify composite B-tree keys #10358) merged and owns bit 22 as FLAG_BTREE_KEY_LAYOUT, and docs(format): add decimal:32 and decimal:64 logical types for Lance 2.3 #11593 assigns bit 23 to FLAG_DECIMAL32_AND_DECIMAL64.
  • Update the index, data-overlay, and format-versioning specifications with the coverage semantics, version 1 expression grammar, query soundness rule, and dependency set (fields ∪ covering_fields ∪ predicate.fields).

Scope

  • Spec, proto, and the reserved flag only. No code reads or sets IndexMetadata.predicate or FLAG_INDEX_PREDICATES yet.
  • Readers and writers in this build reject manifests with FLAG_INDEX_PREDICATES set instead of treating a partial index as covering every row or dropping its predicate on the next commit.

Blast Radius

Existing manifests do not set IndexMetadata.predicate or bit 24, so wire decoding and feature-flag checks for existing datasets are unchanged.

Testing

  • python3 ci/check_proto_comments.py
  • python3 ci/check_module_size.py origin/main
  • cargo fmt --all -- --check
  • cargo test -p lance-table feature_flags --lib
  • cargo test -p lance-table format::index --lib
  • RUSTDOCFLAGS='-D warnings' cargo doc -p lance-table --no-deps
  • cargo clippy --all --tests --benches -- -D warnings
  • cd docs && uv run mkdocs build

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@github-actions github-actions Bot added A-format On-disk format: protos and format spec docs format-change A change to the format spec, which requires a vote. Remove if minor (e.g. fixing typo). enhancement New feature or request labels Oct 28, 2026
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Important

Format specification vote

This PR modifies the Lance format specification, so it requires 3 binding +1 votes from PMC members (excluding the proposer), at least one of them on the latest commit, and a minimum 72-hour voting period, weekends excluded, before it can merge. Vote by approving this PR (+1) or requesting changes (−1, a veto). See the voting process.

Approvals carry over across pushes, so a rebase or a typo fix does not send everyone back to re-vote. Whoever approves the latest commit is vouching that nothing substantive has changed since the earlier approvals; if something has, ask for fresh votes.

Status: ❌ Blocked — 0 of 3 required approvals

Approvals none (0/3)
Latest commit approved by none — one PMC member must approve the latest commit
Vetoes none
Voting period elapsed — ended Mon 2026-11-02 19:57 UTC (11:57 PST)

Updated automatically by the format-spec vote gate, which re-checks every 15 minutes — just voted? Re-check now (press Run workflow; leave the input blank to re-check every open format PR). A PMC member may apply the format-waived label to waive the vote for a trivial edit (typo, wording, formatting).

lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 28, 2026
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 28, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 28, 2026
@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. and removed K-approved Latest Gatekeeper recommendation permits acceptance. labels Nov 2, 2026
Main assigned bit 18 to FLAG_ROW_ADDR_INDICES and bit 19 to
FLAG_INLINE_DELETIONS. Move FLAG_INDEX_PREDICATES to bit 21 with
FLAG_UNKNOWN at bit 22, and leave bit 20 masked as unsupported for the
pending composite B-tree key layout flag, as bit 18 was before.

Main now checks in the generated protobuf sources, so regenerate
rust/lance-table/src/pb/lance.table.rs for IndexMetadata.predicate and
IndexPredicate. Main also added a feature flag name table to
lance-tools, so name the new flag there.

Co-authored-by: Cursor <[email protected]>
@Ali2Arslan

Copy link
Copy Markdown
Contributor Author

Merged main. Main has since assigned bit 18 to FLAG_ROW_ADDR_INDICES and bit 19 to FLAG_INLINE_DELETIONS, so this moves FLAG_INDEX_PREDICATES to bit 21 and leaves bit 20 masked as unsupported for #10358, as bit 18 was before. The description is updated to match.

@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 18, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 18, 2026
Ali2Arslan and others added 2 commits November 19, 2026 17:19
Main assigned bit 20 to FLAG_LOCAL_FRAGMENT_ALIASES, bit 21 to
FLAG_DELETION_FILE_PATHS, and IndexMetadata field 14 to
local_fragment_aliases. Move FLAG_INDEX_PREDICATES to bit 23 with
FLAG_UNKNOWN at bit 24, and move IndexMetadata.predicate to field 15.
Bit 22 stays masked as unsupported for the pending composite B-tree key
layout flag.

Name index_predicates after main's new flag names in lance-tools, and
keep main's flags, asserts, and tests, updating its FLAG_UNKNOWN
assertions to bit 24.

Co-authored-by: Cursor <[email protected]>
Main now assigns bit 22 to FLAG_BTREE_KEY_LAYOUT with FLAG_UNKNOWN at
bit 23. Keep FLAG_INDEX_PREDICATES at bit 23, move FLAG_UNKNOWN to bit
24, and drop the raw bit 22 mask, which FLAG_BTREE_KEY_LAYOUT now
covers.

Name index_predicates after btree_key_layout in lance-tools, and list
bit 23 as reserved with bits 24 and above unknown in versioning.md.

Co-authored-by: Cursor <[email protected]>
@Ali2Arslan

Copy link
Copy Markdown
Contributor Author

Merged main again. Main now assigns bit 20 to FLAG_LOCAL_FRAGMENT_ALIASES, bit 21 to FLAG_DELETION_FILE_PATHS, and bit 22 to FLAG_BTREE_KEY_LAYOUT from #10358, so FLAG_INDEX_PREDICATES moves to bit 23. Main also uses IndexMetadata field 14 for local_fragment_aliases, so predicate moves to field 15, and the description is updated to match.

@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 20, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 20, 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)

@Xuanwo Xuanwo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-assisted technical review of 2065c44e

Main now reserves bit 23 in both the reader and writer flags for FLAG_DECIMAL32_AND_DECIMAL64 (#11593). The spec, Rust constant, and assertions here still use bit 23 for FLAG_INDEX_PREDICATES. Please rebase and coordinate with #10459 on distinct free bits for the two proposals, then update the predicate spec, constant, and assertions together. Merged flag assignment

Main now assigns bit 23 to FLAG_DECIMAL32_AND_DECIMAL64 with
FLAG_UNKNOWN at bit 24. Move FLAG_INDEX_PREDICATES to bit 24 and
FLAG_UNKNOWN to bit 25, and update main's FLAG_UNKNOWN assertions to
match. IndexMetadata.predicate stays field 15.

Name index_predicates after decimal32_and_decimal64 in lance-tools,
and list bit 24 as reserved with bits 25 and above unknown in
versioning.md.

Co-authored-by: Cursor <[email protected]>
@Ali2Arslan

Copy link
Copy Markdown
Contributor Author

Merged main again. Main now assigns bit 23 to FLAG_DECIMAL32_AND_DECIMAL64 from #11593, so this moves FLAG_INDEX_PREDICATES to bit 24 and FLAG_UNKNOWN to bit 25. IndexMetadata.predicate stays field 15. The description is updated to match.

@xgbtxy, #10459 also claims bit 23, for FLAG_VERSIONED_INVERTED_INDEX. To keep the two proposals on distinct bits, I propose this PR takes bit 24 and #10459 takes bit 25. If #10459 merges first, I will move this PR to the next free bit.

@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Dec 1, 2026

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Gate recommendation: approve.

The merge update moves predicates to bit 24, avoiding the merged Decimal32/Decimal64 allocation. Protobuf field 15 and the predicate contract are unchanged; both readers and writers continue to reject the reserved capability.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Dec 1, 2026
xgbtxy added a commit to xgbtxy/lance that referenced this pull request Dec 2, 2026
… move flag bit to 2^25

Upstream main reserved bit 23 for FLAG_DECIMAL32_AND_DECIMAL64 (lance-format#11593), and pending lance-format#10431 reserves bit 24 for FLAG_INDEX_PREDICATES. Coordinate on distinct writer bit 25 (1 << 25) across docs/src/format/table/versioning.md, protos/table.proto, and rust/lance-table/src/pb/lance.table.rs.

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-format On-disk format: protos and format spec docs enhancement New feature or request format-change A change to the format spec, which requires a vote. Remove if minor (e.g. fixing typo). K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants