mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-26 12:33:59 +00:00
feat(nodejs): add Enterprise table override APIs (#5077)
Add TypeScript `getTableOverrides`, `updateTableOverrides`, and `resetTableOverrides` for LanceDB Enterprise tables, delegating to the shared Rust implementation used by Python. Document that updates perform GET → recursive local merge → full PUT. Unrelated fields are preserved from the read snapshot, but concurrent edits can be overwritten. CLI `set` and REST PUT retain replacement semantics. Fix an empty SDK update to return the current snapshot without a PUT. Live testing found that the previous implementation submitted an empty replacement and failed when no overrides were configured. The fix applies to Python, Rust, and TypeScript. Add mock HTTP/local coverage and an opt-in Enterprise integration suite for namespaces, branch isolation, REST replacement, validation failures, historical handles, and empty updates.
This commit is contained in:
@@ -1380,7 +1380,11 @@ class RemoteTable(Table):
|
||||
return LOOP.run(self._table.get_table_overrides())
|
||||
|
||||
def update_table_overrides(self, **overrides: Any) -> dict[str, Any]:
|
||||
"""Merge Enterprise table overrides into the current table overrides."""
|
||||
"""Merge Enterprise table overrides using a non-atomic read-modify-write.
|
||||
|
||||
See [the async method][lancedb.AsyncTable.update_table_overrides]
|
||||
for merge behavior and concurrency limitations.
|
||||
"""
|
||||
return LOOP.run(self._table.update_table_overrides(**overrides))
|
||||
|
||||
def reset_table_overrides(self) -> dict[str, Any]:
|
||||
|
||||
@@ -2115,8 +2115,16 @@ class Table(ABC):
|
||||
def update_table_overrides(self, **overrides: Any) -> dict[str, Any]:
|
||||
"""Merge Enterprise table overrides into the current table overrides.
|
||||
|
||||
Only fields supplied in ``overrides`` are changed; unrelated existing
|
||||
overrides are preserved by the remote service update flow.
|
||||
Fetches the current overrides, recursively merges nested objects locally,
|
||||
then sends the complete replacement using REST PUT. Other values replace
|
||||
existing values; unrelated fields from the read snapshot are preserved.
|
||||
This read-modify-write is not atomic: concurrent edits can be overwritten,
|
||||
even to unrelated fields. Coordinate writers when concurrent edits must
|
||||
be preserved. An empty update only reads and returns the current overrides.
|
||||
|
||||
Unlike this SDK method, CLI ``set`` and REST PUT replace the overrides
|
||||
object without merging. Use ``reset_table_overrides()`` to clear all
|
||||
overrides. Supported only on remote Enterprise tables.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
@@ -6183,8 +6191,16 @@ class LanceTable(Table):
|
||||
def update_table_overrides(self, **overrides: Any) -> dict[str, Any]:
|
||||
"""Merge Enterprise table overrides into the current table overrides.
|
||||
|
||||
Only fields supplied in ``overrides`` are changed; unrelated overrides
|
||||
from the current read snapshot are preserved.
|
||||
Fetches the current overrides, recursively merges nested objects locally,
|
||||
then sends the complete replacement using REST PUT. Other values replace
|
||||
existing values; unrelated fields from the read snapshot are preserved.
|
||||
This read-modify-write is not atomic: concurrent edits can be overwritten,
|
||||
even to unrelated fields. Coordinate writers when concurrent edits must
|
||||
be preserved. An empty update only reads and returns the current overrides.
|
||||
|
||||
Unlike this SDK method, CLI ``set`` and REST PUT replace the overrides
|
||||
object without merging. Use ``reset_table_overrides()`` to clear all
|
||||
overrides. Supported only on remote Enterprise tables.
|
||||
|
||||
Examples
|
||||
--------
|
||||
@@ -6962,8 +6978,16 @@ class AsyncTable:
|
||||
async def update_table_overrides(self, **overrides: Any) -> dict[str, Any]:
|
||||
"""Merge Enterprise table overrides into the current table overrides.
|
||||
|
||||
Only fields supplied in ``overrides`` are changed; unrelated overrides
|
||||
from the current read snapshot are preserved.
|
||||
Fetches the current overrides, recursively merges nested objects locally,
|
||||
then sends the complete replacement using REST PUT. Other values replace
|
||||
existing values; unrelated fields from the read snapshot are preserved.
|
||||
This read-modify-write is not atomic: concurrent edits can be overwritten,
|
||||
even to unrelated fields. Coordinate writers when concurrent edits must
|
||||
be preserved. An empty update only reads and returns the current overrides.
|
||||
|
||||
Unlike this SDK method, CLI ``set`` and REST PUT replace the overrides
|
||||
object without merging. Use ``reset_table_overrides()`` to clear all
|
||||
overrides. Supported only on remote Enterprise tables.
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
@@ -4016,6 +4016,23 @@ def test_update_table_overrides_sync_remote_table_merges_existing_fields():
|
||||
assert calls == ["GET", "PUT"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("current", [{}, {"custom": {"keep": True}}])
|
||||
def test_empty_update_table_overrides_only_reads(current):
|
||||
calls = []
|
||||
|
||||
def overrides_handler(request, parsed):
|
||||
calls.append(request.command)
|
||||
assert request.command == "GET"
|
||||
assert parsed.path == "/admin/table/overrides"
|
||||
assert_table_overrides_query(parsed)
|
||||
send_json(request, current)
|
||||
|
||||
with table_overrides_test_table(overrides_handler) as table:
|
||||
assert table.update_table_overrides() == current
|
||||
|
||||
assert calls == ["GET"]
|
||||
|
||||
|
||||
def test_reset_table_overrides_sync_remote_table():
|
||||
def overrides_handler(request, parsed):
|
||||
assert request.command == "POST"
|
||||
|
||||
Reference in New Issue
Block a user