Skip to content

Add --with-row-id / --with-row-addr output columns (Lance) - #44

Merged
jonasdedden merged 3 commits into
mainfrom
feat/issue-21-row-ids
Jul 22, 2026
Merged

jonasdedden merged 3 commits into
mainfrom
feat/issue-21-row-ids

Conversation

@jonasdedden

Copy link
Copy Markdown
Owner

Adds --with-row-id/--with-row-addr (Lance only) to cat, head, tail, take, and sample: appends _rowid (stable across deletions; across compaction only with Lance stable row ids) and/or _rowaddr (fragment_id << 32 | offset) as trailing UInt64 columns, consistent across scan and take paths and correct across deletions. Excluding a requested pseudo-column errors with a hint; a Dataset::supports_row_id capability hook rejects unsupported formats cleanly. Includes the review commit (stability-doc corrections, added tests, per-input capability check in cat).

Rebased onto current main over #19/#11/#13/#22/#14: threaded row_ids alongside #14's progress params in the mandated render→progress→rowids order across the five commands; stitched the interleaved diff/row-id test sections in tests/cli.rs; fixup gives #22's blob the new Dataset::take RowIds argument (defaulting off) and adapts cat's #14 glob-expanded inputs.

Verified live: --with-row-id --with-row-addr output parses through jq; progress stays TTY-gated. Gates: fmt/clippy clean, 329 tests / 0 failures.

Closes #21

🤖 Generated with Claude Code

jonasdedden and others added 3 commits July 22, 2026 12:04
Surface Lance row identity on the row-producing commands. `--with-row-id`
appends the stable per-row `_rowid`; `--with-row-addr` appends the physical
`_rowaddr` (`fragment_id << 32 | offset`). Both are UInt64, may be combined,
and are appended after the projected columns (`_rowid` before `_rowaddr`),
matching Lance's scanner convention.

- Extend `ScanOptions` with a `row_ids: RowIds` field and thread a `RowIds`
  argument through `Dataset::take`; add a `Dataset::supports_row_id` capability
  hook (default false, Lance true) so the flags fail cleanly with "not supported
  by this format" on other backends.
- Scan path uses `Scanner::with_row_id()` / `with_row_address()`. Take path
  requests the pseudo-columns via `ProjectionRequest::from_columns`
  (which preserves system columns) and reassembles the output in canonical
  `[projected…, _rowid, _rowaddr]` order so `take`/`tail`/`sample` match the
  streaming scan and the writer header exactly.
- New `row_id` module owns the constants, projection cleaning (strip redundant
  system columns from `--columns`), the exclude-while-flagged error, and the
  output-schema extension. The pseudo-columns are always emitted when flagged
  regardless of `--columns`/`--exclude-columns`; explicitly excluding one errors
  with a hint to drop the flag.
- Flags on `cat`, `head`, `tail`, `take`, `sample`.
- Tests: cross-command consistency, non-contiguous `_rowid` after deletion,
  projection/exclude combos, exclusion error, both flags together, and the
  tail/sample/take paths. README + CHANGELOG document both identifiers.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Reviewer follow-ups on the approved branch (no re-review required):

1. Correct the `_rowid` stability claims. Lance 4.0's `enable_stable_row_ids`
   defaults to FALSE, so for default-written datasets `_rowid` is address-based
   (equals `_rowaddr`) and is rewritten by compaction. Reword the README table,
   surrounding prose, the `--with-row-id` clap help, and the CHANGELOG to say
   "stable across deletions; stable across compaction only for datasets written
   with Lance's stable row ids enabled".
2. `cat` now checks row-id capability for every opened dataset in the open loop,
   not just the first, so a future mixed-format concatenation is covered.
3. New tests: nested projection + row ids through the `take` path (exercising
   `assemble_take_output`), `_rowid` stability across `--version`, and a CSV
   rendering assertion for the appended UInt64 columns.
4. Comment at the `ProjectionRequest::from_columns` take call site noting Lance
   internally `.unwrap()`s `project_preserve_system_columns`, and that arrs's
   prior projection validation (plus `RowIds`-only system names) is what keeps
   that infallible.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
blob (#22) and cat's glob expansion (#14) post-date this branch; give
blob's Dataset::take call the new RowIds parameter (defaulting off) and
iterate cat's expanded inputs by reference.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jonasdedden
jonasdedden enabled auto-merge (squash) July 22, 2026 10:08
@jonasdedden
jonasdedden merged commit 82848e3 into main Jul 22, 2026
4 checks passed
@jonasdedden
jonasdedden deleted the feat/issue-21-row-ids branch July 22, 2026 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lance: --with-row-id / --with-row-addr output columns

1 participant