Skip to content

feat(namespace-dir): implement update_table and delete_from_table#6923

Open
XuQianJin-Stars wants to merge 1 commit into
lance-format:mainfrom
XuQianJin-Stars:feature/implement-update-delete-table
Open

feat(namespace-dir): implement update_table and delete_from_table#6923
XuQianJin-Stars wants to merge 1 commit into
lance-format:mainfrom
XuQianJin-Stars:feature/implement-update-delete-table

Conversation

@XuQianJin-Stars
Copy link
Copy Markdown
Contributor

Closes #6922

Summary

DirectoryNamespace (the filesystem-backed LanceNamespace implementation in
rust/lance-namespace-impls/src/dir.rs) currently falls back to the trait's
default "Not supported" implementation for two DML operations. This PR wires
them up to Lance core, on par with what Dataset::update / Dataset::delete
already provide for direct dataset access.

Method Backed by
update_table(UpdateTableRequest) -> UpdateTableResponse lance::dataset::write::UpdateBuilder
delete_from_table(DeleteFromTableRequest) -> DeleteFromTableResponse Dataset::delete(predicate)

Both methods are already exposed on the Java side (DirectoryNamespace.java
updateTable / deleteFromTable) and by lance-namespace-reqwest-client, so
this PR is Rust-only and unblocks the existing client surface.

Changes

update_table

  • Builds an UpdateBuilder by setting each [column, expression] pair from
    the request, applies the optional predicate via update_where, and
    returns the actual rows_updated and the new dataset version.
  • Validates the updates list up-front (non-empty list, exactly two
    elements per pair, non-empty / duplicate-free column names) so callers get
    a clean InvalidInput instead of an opaque DataFusion parse error.

delete_from_table

  • Rejects empty / whitespace-only predicates with InvalidInput.
  • Delegates to Dataset::delete and returns the new dataset version.
  • The trait response model has no deleted_rows field, so the
    DeleteResult.num_deleted_rows returned by Lance core is intentionally
    dropped at the namespace boundary (documented in code).

Error mapping

Cause Mapped error
Predicate / expression parsing failures (DataFusionError) InvalidInput
Underlying lance_core::Error::InvalidInput from delete InvalidInput
Missing table (load_dataset) TableNotFound
Other failures Internal

Tests

7 new unit tests in dir::tests::e2e_table_version_tracking:

  • test_update_full_table — full-table update bumps version by 1
  • test_update_with_predicate — only matching rows updated
  • test_update_invalid_expression_returns_invalid_input
  • test_update_rejects_duplicate_columns
  • test_delete_with_predicate — row count decreases, version + 1
  • test_delete_empty_predicate_returns_invalid_input
  • test_delete_table_not_found

Adds two DML methods that previously fell back to the trait default
'Not supported' implementations:

- update_table: builds an UpdateBuilder by setting each [column, expression]
  pair from the request, applies the optional predicate via update_where,
  and returns the actual rows_updated and new dataset version. Validates
  the updates list (non-empty, two-element pairs, non-empty/duplicate-free
  column names) up front to surface clean InvalidInput errors.

- delete_from_table: rejects empty/whitespace predicates with InvalidInput,
  delegates to Dataset::delete, and returns the new dataset version. The
  trait response model has no deleted_rows field, so we only surface the
  version (the Lance core DeleteResult.num_deleted_rows is intentionally
  dropped at the namespace boundary).

Error mapping:
- Predicate / expression parsing failures -> InvalidInput
- Underlying lance_core::Error::InvalidInput from delete -> InvalidInput
- Missing table -> TableNotFound (via load_dataset)
- Other failures -> Internal

Tests (7) added in dir::tests::e2e_table_version_tracking:
- test_update_full_table
- test_update_with_predicate
- test_update_invalid_expression_returns_invalid_input
- test_update_rejects_duplicate_columns
- test_delete_with_predicate
- test_delete_empty_predicate_returns_invalid_input
- test_delete_table_not_found

cargo fmt / clippy / test all green (dir::tests 122 passed, 0 failed).
Copy link
Copy Markdown

@claude claude Bot left a comment

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
Copy link
Copy Markdown
Contributor

ACTION NEEDED
Lance follows the Conventional Commits specification for release automation.

The PR title and description are used as the merge commit message. Please update your PR title and description to match the specification.

For details on the error please inspect the "PR Title Check" action.

@XuQianJin-Stars XuQianJin-Stars changed the title feat(DirectoryNamespace): implement update_table and delete_from_table feat(namespace-dir): implement update_table and delete_from_table May 23, 2026
@github-actions github-actions Bot added the enhancement New feature or request label May 23, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 23, 2026

Codecov Report

❌ Patch coverage is 84.75610% with 25 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
rust/lance-namespace-impls/src/dir.rs 84.75% 25 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(DirectoryNamespace): implement update_table and delete_from_table DML methods

1 participant