Skip to content

feat: collect zone map write seeds for unindexed columns from dataset config - #11373

Open
LuQQiu wants to merge 26 commits into
lance-format:mainfrom
LuQQiu:lu/zone-write-seeds-config
Open

LuQQiu wants to merge 26 commits into
lance-format:mainfrom
LuQQiu:lu/zone-write-seeds-config

Conversation

@LuQQiu

@LuQQiu LuQQiu commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem

A write collects zone map statistics for a column only if a ZoneMap index already requests seeds. If the index is created after the data is written, its first build must scan that column in every unseeded fragment. Enabling use_seeds on the index cannot recover statistics from those earlier writes.

Why

  • A dataset setting lets the writer collect statistics while it has the column values, before anyone chooses which columns to index. Selecting eligible columns from the write schema also avoids requiring a per-column allow-list in advance. Collection stays opt-in because its append cost varies by type and by whether the seed records null positions.
  • Collection and format compatibility are separate decisions. Version 0 can store these optional statistics without changing what readers must understand. Setting the reader feature flag as a side effect of collection would exclude older readers even for tables writing version 0. The existing version 1 opt-in is the point where that compatibility requirement applies.
  • An existing seeded index already specifies its zone size and whether it needs null positions. Giving those requirements precedence preserves its write behaviour. The dataset settings supply defaults for columns without such a request.

What changed

Dataset::update_config accepts three collection settings. The fourth key below is the existing format control from #11433. All four are documented in the table config and zone write seed specs. The spec leaves the choice of seeded column types to the writer.

Dataset config key Accepted values Behaviour when absent
lance.zone_write_seeds.enabled "true" or "false" Dataset-level collection is off.
lance.zone_write_seeds.rows_per_zone Integer in 1..=u32::MAX Use 8192 rows per configured seed zone.
lance.zone_write_seeds.store_null_bitmap "true" or "false" Record null positions.
lance.zone_write_seeds.version "0" or "1" Write version 0 until the table opts into version 1. Once the flag is set, write version 1 unless explicitly pinned to "0".
  • Column selection. With collection enabled, the writer seeds eligible top-level booleans, integers, floats, dates, times, timestamps, durations, Decimal128/256, strings, and binary columns, including large strings, large binary and fixed-size binary. It skips nested types, vectors, dictionaries, blobs and extension-typed columns. A column whose seed is supplied by another index type has no slot for an additional ZoneMap seed.
  • Index precedence. Usable ZoneMap indices with use_seeds = true share one seed per column. The writer uses their smallest rows_per_zone and records null positions if any of them needs a bitmap. If no such request can be resolved, the dataset settings apply. An index with use_seeds = false does not suppress configured collection.
  • Null positions. At either seed version, a configured seed with positions can serve indices with or without a null bitmap. With store_null_bitmap = false, the seed still records null counts, but a build that needs null positions must scan.
  • Snapshot and format. Each write uses its dataset snapshot. Enabling collection does not backfill files or affect a write based on an earlier snapshot. Disabling collection or changing the zone size affects subsequent configured writes. The three collection keys are covered by the usual FLAG_TABLE_CONFIG writer flag. Only an explicit write of version = "1" activates FLAG_ZONE_WRITE_SEEDS in both the reader and writer flag words. Collection and version can be set in one update. Pinning the version back to "0" changes subsequent writes and leaves the flag set.
  • Commit validation. Both the legacy manifest path, including UpdateConfig and Overwrite, and the composite action path compare the previous and final lance.zone_write_seeds.* settings. If any value under the prefix changes, the commit validates every known key under it. Unknown keys are preserved. A composite can repair an invalid intermediate value before commit. An inherited invalid collection value does not block an unrelated update or a rewrite that leaves the settings identical. When a writer encounters an invalid collection value from an older manifest, it warns and uses that key’s default.
  • Binary-copy compaction. For a carried seed, the output declares the smallest zone size requested by a usable seeded ZoneMap index, then falls back to the enabled dataset setting, then to the writer default. Previously, the last ZoneMap index with a size could determine the result even if it did not use seeds. The existing version 1 carry rules and the ZoneMap index format are unchanged.

Performance

Measurement note. The first local NVMe series predates #11433, when enabling collection also selected version 1. Its seed-enabled arms measured version 1. The full series was not repeated for version 0. At this PR’s HEAD, enabling collection alone writes version 0 on a table that has never opted into version 1. The narrow-type build times below also require an index that uses seeds.

Local NVMe, version 1

Single-column tables on local NVMe, aarch64, 16 cores. Each arm used the same binary and identical pre-generated data. A single call appended 100M rows at 1M rows per file, except for the 7.9M-row case identified in the table. Results are medians of 3 repetitions. The ZoneMap index used rows_per_zone = 1,000,000.

With 2% nulls at random positions, the append columns compare collection off with collection on, first without null positions and then with them. The last column compares building the index by scanning the column with building it from seeds.

Type off (s) on, no null positions on, null positions Index build, scan → from seeds (s)
int32 0.46 +54% +113% 0.40 → 0.008
int64 0.54 +40% +88% 0.41 → 0.008
float32 0.52 +88% +140% 0.41 → 0.009
float64 0.70 +68% +104% 0.45 → 0.008
date32 0.42 +58% +121% 0.39 → 0.008
timestamp (ms) 1.09 +20% +44% 0.40 → 0.008
boolean 0.26 +254% +352% 0.46 → 0.008
decimal128 1.07 +28% +54% 0.52 → 0.008
utf8, 16 chars 9.97 +6% +9% 0.69 → 0.010
binary, 64 bytes 7.90 +6% +11% 1.33 → 0.012
utf8, 256 chars (7.9M rows) 9.98 +1% +1% 1.82 → 0.030

The absolute collection cost for narrow types was 2 to 7 ns per row against a short local append. Using a seed size of 8192 instead of 1,000,000 added a few percentage points.

On the same local hardware, the int64 comparison varied the fraction of randomly positioned nulls. Percentages are append wall time relative to collection off at the same null fraction. The last column gives the extra bytes per file with positions recorded.

Nulls on, no null positions on, null positions Extra bytes per 1M-row file with positions
0% +56% +55% 2 KB
2% +40% +88% 162 KB
30% +100% +351% 526 KB

A ZoneMap that stores a null bitmap built from seeds with positions in 0.034 s (2% nulls) and 0.084 s (30%), compared with 0.41 s and 0.47 s by scan. Peak RSS showed no clear difference in one observation per arm. Each arm checked the committed config, both feature-flag words and seed presence in the appended files before timing, then compared filtered counts with and without the index.

Object storage, version 0 and clustered nulls

A second series used one branch binary, first on local NVMe and then on same-region S3. Each single-column append wrote 100M rows in one call across 100 files. Results are medians of 3 repetitions on 16 cores. The dataset was reopened before every index build so earlier builds could not warm its file metadata cache. All 162 runs passed the seed-presence and filtered-count checks.

For version 1 seeds and 2% randomly positioned nulls, each set of append percentages is relative to collection off on the same storage.

Type Local off (s) Local, no null positions Local, null positions S3 off (s) S3, no null positions S3, null positions
int64 0.58 +36% +86% 8.03 +9% +16%
boolean 0.27 +247% +347% 4.76 +16% +12%
timestamp (ms) 1.25 +17% +37% 24.71 -2% -1%
utf8, 16 chars 10.18 +6% +8% 35.90 0% +4%

Collection added 0.2 to 1.1 s of CPU time per 100M rows on both storage types. Upload time dominated on S3. Repetitions of one S3 arm differed by 10% or more, putting differences of a few percent, including the negative values, within the observed noise.

The version 1 index-build times below compare a full column scan with reuse of seeds, in seconds.

Type Local S3
int64 0.42 → 0.009 1.00 → 0.62
boolean 0.49 → 0.009 0.98 → 0.66
timestamp (ms) 0.42 → 0.008 1.18 → 0.66
utf8, 16 chars 0.72 → 0.011 1.97 → 0.67

Across these types, a build from seeds on S3 took about 0.6 s for 100 files and avoided reading column data. The measured speedup was 1.3x to 3x on S3, compared with about 50x on local disk. Bytes read, larger file counts and wide columns were not measured in this object-storage comparison.

Version 0. On local NVMe without the version 1 opt-in, int64 matched version 1 (+37% / +88% append without / with null positions, 0.42 → 0.008 s for scan → seed build). For float64, append cost increased (+68% / +103%), while the build took 0.47 s by scan and 0.47 s with seeds available. The generated data contained NaN, and the version 0 records could not supply the required statistics for those zones. On S3 the append difference relative to collection off was within noise for both types (-3% to +6%).

Clustered nulls. On local NVMe, the int64 version 1 comparison held null-position recording on and compared random nulls with runs of 1000 consecutive nulls. Append percentages are relative to collection off. The last column times a bitmap index build from seeds.

Nulls Positions Append Extra bytes per 1M-row file Bitmap index from seeds (s)
2% random +86% 159 KB 0.035
2% clustered +36% 3 KB 0.008
30% random +329% 514 KB 0.090
30% clustered +38% 7 KB 0.010

With clustered nulls, recording positions cost about the same as omitting them. Random positions cost more at both measured null fractions. On S3 the clustered cases added 5% to 6% to the append. End-to-end binary-copy compaction latency on wide tables in object storage was not measured.

Tests

  • Config tests cover defaults, invalid values, and both commit paths. They check that rejection leaves the published config and dataset version intact, that an unknown key survives later changes, that collection and version can be set together, and that validation uses the final composite state. Both paths exercise unrelated updates and unchanged rewrites against an inherited invalid collection value.
  • Write tests cover unindexed scalar columns, type and blob exclusions, seeded-index precedence, and an index with use_seeds = false. They check the feature flags and seed versions across appends from version 0 to version 1 and back to an explicit version 0, plus enable, disable, resize and reopen. An Int64 build compares default use_seeds with explicit true. Bitmap tests check reuse with null positions and fallback to a scan when required positions are absent.
  • Version 1 round trips cover 18 types from seed collection through index build and compare filtered row IDs with an unindexed scan. Boundary tests cover aligned, crossing and coarser seed zones, writer batches that cross zones, short final zones, and unseeded creation fragments. They assert exact reuse and scan counts and compare persisted zone spans, counts and bounds with the generated data. A further 32 type variants exercise mixed reuse and scanning with and without an index null bitmap.
  • Binary-copy tests cover zone-size selection across multiple seeded and unseeded indices, carrying and reusing version 1 inputs collected at different sizes, and dropping version 0 seeds while leaving the seed flag unset on a table without the opt-in.

Known limitations

  • The dataset-creating write has no committed config from which to collect seeds. Create the dataset, set the config, then append to get configured seeds. Overwrite writes and legacy-format data files also collect no seeds.
  • Only top-level fields are eligible. Releases up to and including v14.0.0-beta.16 look up seeds by leaf name during index maintenance. If a nested leaf shares a name with a seeded top-level column, those releases can use the wrong seed and produce incorrect zone statistics. Enabling collection makes that top-level seed present in more files. Releases from v14.0.0-beta.17 resolve the field by identity.
  • A ZoneMap build uses configured seeds only when the index uses seeds. The existing type-based default is false for fixed-width types of 8 bytes or less, including booleans, integers, floats, dates, times, timestamps and durations. Those columns require explicit use_seeds = true on the index to benefit. Variable-length and wider supported types default to true.
  • Version 0 float seed records for zones containing NaN lack the NaN sign counts needed for reuse. Binary-copy compaction also drops version 0 seeds. It carries a column’s seeds only when the table writes version 1 and every contributing input has a compatible version 1 seed for that column.
  • Binary-copy compaction reads each seed of each input file with a separate request during the eligibility check and again during the rewrite. A wide table can therefore issue many requests on object storage. Compaction that re-encodes data avoids this per-seed read pattern.

🤖 Generated with Claude Code

… config

Add two dataset config keys. `lance.zone_write_seeds.enabled` makes writes
embed a zone map seed for every top-level column of a supported scalar type
that no seeded ZoneMap index covers, so a ZoneMap index created later can be
built from seeds instead of scanning. `lance.zone_write_seeds.rows_per_zone`
sets the rows per seed zone for those columns (default 8192). A column with a
seeded ZoneMap index keeps following that index. The commit that enables the
setting also sets the seed feature flags; binary-copy compaction declares the
same zone size for carried seeds.

Co-Authored-By: Claude <[email protected]>
@github-actions github-actions Bot added the enhancement New feature or request label Nov 23, 2026
Reject an invalid lance.zone_write_seeds.* value in the commit that sets it,
as the auto-cleanup keys are validated, instead of falling back on later
writes. Add lifecycle, per-type round-trip and binary-copy carry tests.

Co-Authored-By: Claude <[email protected]>
@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
25187 1 25186 0
View the top 1 failed test(s) by shortest run time
lance-jsonb::it::functions::test_select_by_index_union_is_one_pass
Stack Traces | 0.093s run time
thread 'functions::test_select_by_index_union_is_one_pass' (152225) panicked at ....../tests/it/functions.rs:368:5:
union 7.703206ms vs one pass 11.602538ms
stack backtrace:
   0: __rustc::rust_begin_unwind
             at .../std/src/panicking.rs:679:5
   1: core::panicking::panic_fmt
             at .../core/src/panicking.rs:80:14
   2: test_select_by_index_union_is_one_pass
             at ..../tests/it/functions.rs:368:5
   3: it::functions::test_select_by_index_union_is_one_pass::{closure#0}
             at ..../tests/it/functions.rs:320:44
   4: <it::functions::test_select_by_index_union_is_one_pass::{closure#0} as core::ops::function::FnOnce<()>>::call_once
             at .../src/ops/function.rs:250:5
   5: <fn() -> core::result::Result<(), alloc::string::String> as core::ops::function::FnOnce<()>>::call_once
             at .../src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

LuQQiu and others added 15 commits November 22, 2026 18:00
Zone statistics have no min/max for fixed-size binary, so a seed for such a
column is always rejected by the index build. Also check unseeded nested
columns in the test through every file of the fragment.

Co-Authored-By: Claude <[email protected]>
Check the final manifest once after all actions, as the auto-cleanup settings
are checked. Assert seed reuse in the binary-copy carry test and add value
predicates to the per-type round trip.

Co-Authored-By: Claude <[email protected]>
A Lance field stores view types as their base string or binary type, so the
case asserted on a type the gate never sees.

Co-Authored-By: Claude <[email protected]>
Add lance.zone_write_seeds.store_null_bitmap (default true) so seeds collected
from the dataset config can serve a zone map that stores a null bitmap.

Co-Authored-By: Claude <[email protected]>
Adds a matrix over seed size, index size, fragment length and batch size
that checks which fragments are reused, partly scanned or scanned, and
compares indexed results row by row with the generator and an unindexed
scan.

Co-Authored-By: Claude <[email protected]>
A partly reused fragment is reported as both partial and scanned, and
scanned rows include the unseeded creating fragment. Corrects the
expectation for 8-row records over 20-row index zones.

Co-Authored-By: Claude <[email protected]>
Asserts the exact outcome for a seed coarser than the index and adds
8192 and 1,000,000-row zone sizes over a fragment length neither divides.

Co-Authored-By: Claude <[email protected]>
Reads every persisted zone of the index built from configured seeds and
checks its span, bounds and null count against values computed from the
generator, including the unseeded creating fragment and short final zones.

Co-Authored-By: Claude <[email protected]>
…ndex

Checks reuse, stored zone statistics and query results for integer,
float, string, timestamp, boolean and decimal columns where reused and
scanned zones mix.

Co-Authored-By: Claude <[email protected]>
@LuQQiu
LuQQiu marked this pull request as ready for review November 24, 2026 04:38
@LuQQiu

LuQQiu commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@claude review

@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.

@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.

Code review found no issues

No high-confidence issues detected in this change.

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 24, 2026
Xuanwo added a commit that referenced this pull request Nov 24, 2026
…v0 writes by default (#11433)

## Summary

Fixes a cross-version compatibility break introduced by #10102 before
releasing Lance v15.0.0.

### Problem

Since Lance v10 (#7427), `ZoneMap` indices on string, binary, decimal,
fixed-size binary (>8 bytes), and nested columns default to `use_seeds =
true`. In #10102, any commit on a dataset carrying a `use_seeds = true`
ZoneMap index automatically set `FLAG_ZONE_WRITE_SEEDS` (`1 << 16`) in
both `reader_feature_flags` and `writer_feature_flags`.

Because `v14.0.0` reserves bit 16 as unsupported and `v15.0.0` is the
first stable release able to read it, automatic activation breaks
rolling upgrades: a single v15 writer performing any normal commit
(`Append`, `Update`, `Delete`, `DataReplacement`, `Compact`, etc.)
permanently (sticky bit) locks out all Lance `< 15` readers with no
rollout window. This also diverged from the zone write seeds format spec
(#9564, `docs/src/format/index/scalar/zone_write_seeds.md`, *"Activation
is explicit, not triggered by opening a table"*) and from every other
v15 reader feature flag (`FLAG_MANAGED_BLOBS`,
`FLAG_SPILLED_ROW_LINEAGE`, `FLAG_INLINE_DELETIONS`), all of which
require explicit opt-in.

### Changes

- **Remove automatic activation**: Remove `apply_seed_feature_flags`
from the commit path (`rust/lance/src/io/commit.rs`,
`rust/lance/src/dataset/write/seeds.rs`). Normal commits and
`CreateIndex` no longer set `FLAG_ZONE_WRITE_SEEDS`.
- **Add explicit opt-in config**: Add dataset config key
`lance.zone_write_seeds.version` (valid values `"0"` and `"1"`)
validated when modified on both legacy (`UpdateConfig`, `Overwrite`) and
composite transaction paths (`rust/lance-table/src/feature_flags.rs`,
`rust/lance-table/src/transaction/`).
- Absent or `"0"`: `FLAG_ZONE_WRITE_SEEDS` stays unset; writers emit v0
seeds.
- `"1"`: Atomically sets `FLAG_ZONE_WRITE_SEEDS` in both
`reader_feature_flags` and `writer_feature_flags`. Once set, the flag
remains sticky across subsequent commits, index drops, restores, and
clones; setting `"0"` pins future writes back to v0 while keeping the
flag sticky.
- Designed to live in the same `lance.zone_write_seeds.*` namespace as
#11373.
- **Keep v0 write seeds by default**: Add `ZoneMapSeedVersion::{V0, V1}`
to `ZoneMapSeedWriter` (`rust/lance-index/src/scalar/zonemap.rs`).
Tables that have not activated `FLAG_ZONE_WRITE_SEEDS` (or are pinned to
`"0"`) emit v0 seeds (no `version` metadata, no `negative_nan_count`,
`max = +NaN` when `nan_count > 0`, `required_feature_flags() == 0`).
This preserves Lance `< 15` read/write compatibility **without**
regressing `optimize_indices` performance (since #10165 already reuses
v0 seeds with `nan_count == 0`, covering all non-float and NaN-free
float zones).
- **Binary-copy compaction**: Carry v1 seeds when
`write_v1_zone_write_seeds` is true; otherwise drop v0 seeds cleanly
without activating `FLAG_ZONE_WRITE_SEEDS`
(`rust/lance/src/dataset/optimize/binary_copy.rs`).
- **Tests**:
- Updated and expanded unit/integration tests across `lance-table`,
`lance-index`, and `lance` covering v0 default writes, explicit v1
opt-in, sticky flag behavior, config validation, binary-copy compaction,
and external scalar plugins.
- Extended `ZonemapBloomfilterIndex` in
`python/python/tests/compat/test_scalar_indices.py` with a string column
(which defaults to `use_seeds=True` on Lance >= 10) so the compat matrix
catches write-seed regressions going forward.

## Verification

- `cargo test --profile ci -p lance-table --lib --doc`
- `cargo test --profile ci -p lance-index --lib zonemap`
- `cargo test --profile ci -p lance --lib -- seed` / `binary_copy` /
`zone_map`
- `cargo test --profile ci -p lance --test external_scalar_plugin`
- `cargo fmt --all -- --check` & `cargo clippy --profile ci --all
--tests --benches -- -D warnings`
- `cd python && uv run make lint` (ruff, pyright, cargo fmt, cargo
clippy)
- Smoke-tested `ZonemapBloomfilterIndex` locally against the built
`pylance` wheel
@Xuanwo

Xuanwo commented Nov 24, 2026

Copy link
Copy Markdown
Member

Heads-up for rebasing onto main: #11433 just merged to keep FLAG_ZONE_WRITE_SEEDS explicit opt-in for v15 rolling upgrades (avoiding silently locking out Lance < 15 readers on existing seeded ZoneMap tables). A few overlap points with this PR:

  1. Config prefix validation: fix(index): require explicit opt-in for v1 zone write seeds and keep v0 writes by default #11433 added lance.zone_write_seeds.version ("0" / "1", ZONE_WRITE_SEEDS_VERSION_KEY). validate_zone_write_seeds_config will need to allow this key under lance.zone_write_seeds. alongside enabled, rows_per_zone, and store_null_bitmap.
  2. Explicit FLAG_ZONE_WRITE_SEEDS activation: fix(index): require explicit opt-in for v1 zone write seeds and keep v0 writes by default #11433 removed apply_seed_feature_flags from the commit path; FLAG_ZONE_WRITE_SEEDS is now activated only when a commit explicitly writes lance.zone_write_seeds.version = "1" (apply_zone_write_seeds_version_config), while unactivated tables emit v0 seeds (ZoneMapSeedVersion::V0) via write_v1_zone_write_seeds(manifest). Unindexed seed writers created from lance.zone_write_seeds.enabled = "true" can follow the same zone_map_seed_version so v15 writes stay < 15-compatible by default until version = "1" is opted in.
  3. Binary-copy seed carry: fix(index): require explicit opt-in for v1 zone write seeds and keep v0 writes by default #11433 gated seed_acc.finish(...) on write_v1_zone_write_seeds(&dataset.manifest) so v0 seeds are dropped without setting FLAG_ZONE_WRITE_SEEDS; unindexed_rows_per_zone can stay inside that same gate.

Happy to take another look once this is rebased!

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

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot removed K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Dec 2, 2026

@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.

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

Additional findings (outside the current diff — GitHub can't attach inline comments there):

  • 🟡 rust/lance-table-runtime/src/optimize/binary_copy.rs — Binary-copy compaction on tables with lance.zone_write_seeds.enabled gets much slower. Every input file now has one seed per scalar column, and each is read one request at a time, twice. extract_source_seeds (seed_carry.rs:134) awaits one submit_single per seed. It runs in the gate (execution.rs:230) and again at binary_copy.rs:393. On version 0 tables those seeds are then thrown away by seed_acc.clear(). Fix: read all of a file's seed buffers in one batched request, or reuse the tail read. Also skip the second read when carry_v1_seeds is false, since the gate has already checked the buffers.

    Why this was flagged

    Trigger: a table sets lance.zone_write_seeds.enabled=true, receives many small appends, then runs compaction with try-binary-copy or force-binary-copy. Writes now attach a seed to every supported top-level column (seeds.rs:251-264). On the base branch only columns with a seeded ZoneMap index got one. can_use_binary_copy_current (execution.rs:229-242) calls extract_source_seeds, which loops over every lance.seed.* key. Each pass awaits a separate file_scheduler.submit_single(...) and fully decodes the buffer (seed_carry.rs:85-153). rewrite_files_binary_copy repeats the same reads at binary_copy.rs:393. On a version 0 table, which is the default when only enabled is set, carry_v1_seeds is false and the bytes are dropped at binary_copy.rs:401. So a 100-column table compacting 500 small files issues about 100,000 extra sequential small object-store GETs. The gate exists to check that buffers are safe, not to keep the work cheap.

    Verification: extract_source_seeds (seed_carry.rs:85-136) loops over every lance.seed.* metadata key. Each pass awaits its own file_scheduler.submit_single(...), so a file's seeds are read one after another. The function runs once in the gate (execution.rs:229-235) and again at binary_copy.rs:393. When carry_v1_seeds is false, the bytes are thrown away by seed_acc.clear().

lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. and removed K-risk Latest Gatekeeper recommendation includes a non-blocking risk. K-approved Latest Gatekeeper recommendation permits acceptance. labels Dec 2, 2026
…commit paths

Both paths now validate every setting under the prefix when a commit
changes any of them, so rewriting an inherited value unchanged is not
blocked by a value that was already invalid. Also correct the spec on
which feature flags the keys set and list the writes that collect no
seed.

Co-Authored-By: Claude <[email protected]>
@LuQQiu

LuQQiu commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

@claude review

@lance-gatekeeper lance-gatekeeper Bot removed K-risk Latest Gatekeeper recommendation includes a non-blocking risk. K-approved Latest Gatekeeper recommendation permits acceptance. labels Dec 2, 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 with a non-blocking risk.

Both commit paths now compare the final zone-seed settings, so rewriting an unchanged inherited collection setting no longer rejects the commit. All 77 focused zone-seed tests passed, including explicit and sticky version activation. Collection remains opt-in, preserves seeded-index precedence and unknown settings, and requires use_seeds=true for narrow columns. The documented v0 limitations remain: binary copy drops its seeds, and float zones containing NaN fall back to scanning.

The remaining binary-copy performance risk affects wide tables on object storage. Above the small-file cache threshold, eligibility checking and rewriting each read seeds serially, including v0 seeds that are then discarded. The earlier extractor experiment confirmed 200 range reads for 100 seeds across two passes; end-to-end cloud latency remains unmeasured. reencode compaction avoids that request pattern at the cost of re-encoding.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Dec 2, 2026

@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.

Code review completed

Nothing new to post: everything this review found is already covered by existing comments on this pull request or didn't merit a separate one.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. and removed K-risk Latest Gatekeeper recommendation includes a non-blocking risk. K-approved Latest Gatekeeper recommendation permits acceptance. labels Dec 2, 2026

@wjones127 wjones127 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.

Thanks for the quick turnaround. Both blockers from my last pass are resolved: table_config.md documents all four keys and what other implementations must do with them, and seeded_rows_per_zone is pure and tested. Thanks also for picking up FixedSizeBinary right after #11387 landed, and for the object-storage numbers, which answer my cost question. I'm fine leaving a column list for a follow-up.

Nothing blocks, so I'm approving; this counts as my spec vote. Optional feedback, none of it required:

  • (spec) Drop the seeded-type list from the enabled row; it's writer policy, and it already changed once in this PR.
  • (spec) Phrase the paragraph under the table as "must" rules.
  • (tests) The new boundary and per-type matrices build ~43 datasets and indexes to re-test reuse that doesn't depend on the config.
  • (design) The seedable-type predicate could live next to the ZoneMap processor in lance-index.
  • (nit) Re-export ZONE_WRITE_SEEDS_VERSION_KEY.

Comment thread docs/src/format/table/table_config.md Outdated
| `lance.compaction.max_source_rows` | Non-negative integer | Maximum number of live source rows (physical rows minus soft-deleted rows) to compact in a single run. Defaults to unlimited. |
| `lance.compaction.max_source_bytes` | Non-negative integer | Maximum number of source bytes (data files and [data overlay files](data_overlay_file.md), excluding blob v2 payloads) to compact in a single run. Defaults to unlimited. |
| `lance.compaction.max_overlays_per_fragment` | Non-negative integer or `none` | Maximum number of [data overlay files](data_overlay_file.md) a fragment may carry before it is fully compacted (overlays and deletions materialized into the base data). Defaults to `10`. Set to `0` to compact every fragment with any overlay, or `none` to disable the trigger. |
| `lance.zone_write_seeds.enabled` | Boolean (`true`/`false`) | If `true`, writes collect a [zone write seed](../index/scalar/zone_write_seeds.md) for every top-level column of a supported scalar type that no seeded index already covers, so a ZoneMap index created later can be built from seeds instead of rescanning. Supported types are boolean, integer, floating-point, date, time, timestamp, duration, decimal, string, and binary (variable-length or fixed-size); nested, vector, dictionary, extension-typed, and blob columns are never seeded by this key. Columns covered by a ZoneMap index with `use_seeds=true` keep that index's settings. An index build reads these seeds only when the index uses seeds; an index created without an explicit `use_seeds` takes the default for the column's type, which is `false` for fixed-width types of 8 bytes or less (so those columns need `use_seeds=true` to reuse the seeds) and `true` for variable-length and wider types. Defaults to `false`. |

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.

suggestion: Which column types get seeds is writer policy. Seeds are optional, and readers don't care why a column has one. Listing the types here makes the list normative, and it's already moving: the FSB commit just changed it, and once this spec is accepted, a change like that would need another vote. What if the spec only stated intent and left the type choice to the writer?

The "supported column types" pointer in zone_write_seeds.md would need the same trim.

Suggested change
| `lance.zone_write_seeds.enabled` | Boolean (`true`/`false`) | If `true`, writes collect a [zone write seed](../index/scalar/zone_write_seeds.md) for every top-level column of a supported scalar type that no seeded index already covers, so a ZoneMap index created later can be built from seeds instead of rescanning. Supported types are boolean, integer, floating-point, date, time, timestamp, duration, decimal, string, and binary (variable-length or fixed-size); nested, vector, dictionary, extension-typed, and blob columns are never seeded by this key. Columns covered by a ZoneMap index with `use_seeds=true` keep that index's settings. An index build reads these seeds only when the index uses seeds; an index created without an explicit `use_seeds` takes the default for the column's type, which is `false` for fixed-width types of 8 bytes or less (so those columns need `use_seeds=true` to reuse the seeds) and `true` for variable-length and wider types. Defaults to `false`. |
| `lance.zone_write_seeds.enabled` | Boolean (`true`/`false`) | If `true`, writers should collect a [zone write seed](../index/scalar/zone_write_seeds.md) for top-level scalar columns that no seeded index already covers, so a ZoneMap index created later can be built from seeds instead of rescanning. Which column types get seeds is up to the writer. Columns covered by a ZoneMap index with `use_seeds=true` keep that index's settings. An index build reads these seeds only when the index uses seeds. Defaults to `false`. |

Comment thread docs/src/format/table/table_config.md Outdated
Comment on lines +61 to +73
Zone write seeds are optional metadata, so an implementation that does not
write seeds only needs to preserve the `lance.zone_write_seeds.*` keys.
`enabled`, `rows_per_zone`, and `store_null_bitmap` only affect which seeds a
writer collects; they never change what readers must understand and never set
`FLAG_ZONE_WRITE_SEEDS`. Like any table configuration, they are covered by the
[`FLAG_TABLE_CONFIG`](versioning.md#current-feature-flags) writer flag that a
non-empty table config sets. No seed is collected by the write that creates
the dataset, by an overwrite, for data files in the legacy file format, or for
a column whose seed another index type provides. The seed format a writer emits and
[`FLAG_ZONE_WRITE_SEEDS`](versioning.md#current-feature-flags) are governed by
`lance.zone_write_seeds.version` alone. Setting a known key to an invalid
value is rejected by the commit that sets it; unknown keys under the
`lance.zone_write_seeds.` prefix are preserved and not rejected.

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.

suggestion: This paragraph has the right content, but it reads as a description of what this library does. Since it's the part other implementations act on, could it be phrased as rules? Something like:

Zone write seeds are optional metadata. An implementation that does not write seeds must preserve every lance.zone_write_seeds.* key. enabled, rows_per_zone, and store_null_bitmap only choose which seeds a writer collects: they must not change what readers need to understand, and must not set FLAG_ZONE_WRITE_SEEDS. The seed version a writer emits, and whether FLAG_ZONE_WRITE_SEEDS is set, must depend only on lance.zone_write_seeds.version. A commit that sets one of these keys to an invalid value must be rejected. Unknown keys under the lance.zone_write_seeds. prefix must be preserved, not rejected.

The "no seed is collected by the write that creates the dataset…" sentence reads like writer policy too, so maybe it moves to zone_write_seeds.md or goes as a "may".

#[case::seed_coarser_than_index(32, 8, 64, 13)]
#[case::fragment_shorter_than_seed_zone(8, 8, 5, 5)]
#[tokio::test]
async fn test_config_seed_boundary_matrix(

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.

suggestion: The boundary matrix (8 cases), test_config_seed_boundary_real_sizes (3 cases, one with 1.05M-row fragments) and test_config_seed_boundary_per_type (32 cases) each write a dataset and build a ZoneMap index. As far as I can tell, what they check doesn't depend on the config: the config only picks rows_per_zone and the null policy for the same ZoneMapSeedWriter an index would request. Reuse across seed and index zone sizes is already covered for index-requested seeds:

#[rstest::rstest]
#[case::divisible(64, 320, true)]
#[case::whole_fragment(64, 20000, true)]
#[case::whole_fragment_no_bitmap(64, 20000, false)]
#[case::non_divisible_capped(64, 100, true)]
#[case::non_divisible_partial(64, 160, false)]
#[case::phase_shifting(64, 10000, false)]
#[case::same_size(64, 64, true)]
#[tokio::test]
async fn test_create_index_keeps_configured_boundaries(
#[case] s: u64,
#[case] t: u64,
#[case] bitmap: bool,
) {

Could this file keep only the config-specific tests (selection, precedence, lifecycle, one round trip)? If the per-type stored-statistics check fills a real gap, it'd be much cheaper as a unit test on ZoneMapSeedWriter in lance-index. I didn't measure how long these take in CI, so if they're quick, feel free to ignore this.

/// scalar type only. The list is a conservative gate, not a guarantee about
/// collection cost. Blob and extension-typed columns are excluded because
/// the written values are not the column's logical values.
fn config_seed_supports(field: &Field) -> bool {

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.

suggestion: Two crates now know which types can be zone-seeded: ZoneMapProcessor::new in lance-index decides what ZoneMapSeedWriter::new accepts, and this allow-list narrows it here in lance. FixedSizeBinary showed the cost: #11387 fixed the stats in lance-index, and the exclusion here then had to be flipped by hand. What if this predicate lived next to the processor, say ZoneMapSeedWriter::supports(&DataType), so changing the stats changes what gets seeded? Blob and extension checks need the Lance Field, so they could stay here. A follow-up is fine.

};
pub use seeds::{
ZONE_WRITE_SEEDS_ENABLED_KEY, ZONE_WRITE_SEEDS_ROWS_PER_ZONE_KEY,
ZONE_WRITE_SEEDS_STORE_NULL_BITMAP_KEY,

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.

nitpick: This re-exports three of the four keys but not ZONE_WRITE_SEEDS_VERSION_KEY, so a user who wants version 1 seeds still has to reach into lance_table::feature_flags. Maybe re-export it here too?

Suggested change
ZONE_WRITE_SEEDS_STORE_NULL_BITMAP_KEY,
ZONE_WRITE_SEEDS_STORE_NULL_BITMAP_KEY, ZONE_WRITE_SEEDS_VERSION_KEY,

…as requirements

Drop the type list from the lance.zone_write_seeds.enabled row, phrase the
paragraph under the table as rules for implementations, and move the cases
where no seed is collected to the zone write seed page as writer latitude.
Also re-export ZONE_WRITE_SEEDS_VERSION_KEY next to the other three keys.
@LuQQiu

LuQQiu commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

@claude review

@lance-gatekeeper lance-gatekeeper Bot removed K-risk Latest Gatekeeper recommendation includes a non-blocking risk. K-approved Latest Gatekeeper recommendation permits acceptance. labels Dec 3, 2026

@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.

Code review found no issues

No high-confidence issues detected in this change.

@BubbleCal BubbleCal 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.

+1 (PMC vote). One non-blocking note.

With collection enabled, an append can write a v0 seed for top-level val even when only st.val has a ZoneMap. Older optimize_indices can use that seed for st.val and persist bounds that cause queries to miss rows. Can we document that index-maintenance clients need the #10003 fix before enabling collection on these tables, and add a mixed-version test that compares indexed results with a flat scan after reopening?

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).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants