From d059447feb0e7b4759bb2bda7608e929e9c36ea2 Mon Sep 17 00:00:00 2001 From: Jack Ye Date: Sat, 11 Apr 2026 23:29:17 -0700 Subject: [PATCH] refactor: rename deserialize to deserialize_conn, consistent pushdown naming - Rename deserialize() -> deserialize_conn() for clarity - Rename internal _pushdown_operations -> _namespace_client_pushdown_operations for consistency with the parameter name - Rename serialized key "pushdown_operations" -> "namespace_client_pushdown_operations" Co-Authored-By: Claude Opus 4.6 (1M context) --- python/python/lancedb/__init__.py | 6 ++++-- python/python/lancedb/namespace.py | 24 +++++++++++++++--------- python/python/tests/test_namespace.py | 16 ++++++++-------- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/python/python/lancedb/__init__.py b/python/python/lancedb/__init__.py index df796fdd9..e69161586 100644 --- a/python/python/lancedb/__init__.py +++ b/python/python/lancedb/__init__.py @@ -237,7 +237,7 @@ def _apply_worker_overrides(props: dict[str, str]) -> dict[str, str]: return result -def deserialize( +def deserialize_conn( data: str, *, for_worker: bool = False, @@ -280,7 +280,9 @@ def deserialize( namespace_client_properties=props, read_consistency_interval=rci, storage_options=storage_options, - namespace_client_pushdown_operations=parsed.get("pushdown_operations"), + namespace_client_pushdown_operations=parsed.get( + "namespace_client_pushdown_operations" + ), ) elif connection_type == "local": return LanceDBConnection( diff --git a/python/python/lancedb/namespace.py b/python/python/lancedb/namespace.py index 58e1e011a..0996c63fd 100644 --- a/python/python/lancedb/namespace.py +++ b/python/python/lancedb/namespace.py @@ -419,7 +419,9 @@ class LanceNamespaceDBConnection(DBConnection): self.read_consistency_interval = read_consistency_interval self.storage_options = storage_options or {} self.session = session - self._pushdown_operations = set(namespace_client_pushdown_operations or []) + self._namespace_client_pushdown_operations = set( + namespace_client_pushdown_operations or [] + ) self._namespace_client_impl = namespace_client_impl self._namespace_client_properties = namespace_client_properties @@ -432,7 +434,9 @@ class LanceNamespaceDBConnection(DBConnection): "connection_type": "namespace", "namespace_client_impl": self._namespace_client_impl, "namespace_client_properties": self._namespace_client_properties, - "pushdown_operations": sorted(self._pushdown_operations), + "namespace_client_pushdown_operations": sorted( + self._namespace_client_pushdown_operations + ), "storage_options": self.storage_options or None, "read_consistency_interval_seconds": ( self.read_consistency_interval.total_seconds() @@ -496,7 +500,7 @@ class LanceNamespaceDBConnection(DBConnection): table_id = namespace_path + [name] - if "CreateTable" in self._pushdown_operations: + if "CreateTable" in self._namespace_client_pushdown_operations: return self._create_table_server_side( name=name, data=data, @@ -578,7 +582,7 @@ class LanceNamespaceDBConnection(DBConnection): storage_options=merged_storage_options, location=location, namespace_client=self._namespace_client, - pushdown_operations=self._pushdown_operations, + pushdown_operations=self._namespace_client_pushdown_operations, ) return tbl @@ -919,7 +923,7 @@ class LanceNamespaceDBConnection(DBConnection): location=table_uri, namespace_client=namespace_client, managed_versioning=managed_versioning, - pushdown_operations=self._pushdown_operations, + pushdown_operations=self._namespace_client_pushdown_operations, ) @override @@ -983,7 +987,9 @@ class AsyncLanceNamespaceDBConnection: self.read_consistency_interval = read_consistency_interval self.storage_options = storage_options or {} self.session = session - self._pushdown_operations = set(namespace_client_pushdown_operations or []) + self._namespace_client_pushdown_operations = set( + namespace_client_pushdown_operations or [] + ) async def table_names( self, @@ -1038,7 +1044,7 @@ class AsyncLanceNamespaceDBConnection: table_id = namespace_path + [name] - if "CreateTable" in self._pushdown_operations: + if "CreateTable" in self._namespace_client_pushdown_operations: return await self._create_table_server_side( name=name, data=data, @@ -1118,7 +1124,7 @@ class AsyncLanceNamespaceDBConnection: storage_options=merged_storage_options, location=location, namespace_client=self._namespace_client, - pushdown_operations=self._pushdown_operations, + pushdown_operations=self._namespace_client_pushdown_operations, ) lance_table = await asyncio.to_thread(_create_table) @@ -1225,7 +1231,7 @@ class AsyncLanceNamespaceDBConnection: location=response.location, namespace_client=self._namespace_client, managed_versioning=managed_versioning, - pushdown_operations=self._pushdown_operations, + pushdown_operations=self._namespace_client_pushdown_operations, ) lance_table = await asyncio.to_thread(_open_table) diff --git a/python/python/tests/test_namespace.py b/python/python/tests/test_namespace.py index 1f326e29a..bbf7e4c6f 100644 --- a/python/python/tests/test_namespace.py +++ b/python/python/tests/test_namespace.py @@ -681,7 +681,7 @@ class TestPushdownOperations: {"root": self.temp_dir}, namespace_client_pushdown_operations=["QueryTable"], ) - assert "QueryTable" in db._pushdown_operations + assert "QueryTable" in db._namespace_client_pushdown_operations def test_create_table_pushdown_stored(self): """Test that CreateTable pushdown is stored on sync connection.""" @@ -690,7 +690,7 @@ class TestPushdownOperations: {"root": self.temp_dir}, namespace_client_pushdown_operations=["CreateTable"], ) - assert "CreateTable" in db._pushdown_operations + assert "CreateTable" in db._namespace_client_pushdown_operations def test_both_pushdowns_stored(self): """Test that both pushdown operations can be set together.""" @@ -699,13 +699,13 @@ class TestPushdownOperations: {"root": self.temp_dir}, namespace_client_pushdown_operations=["QueryTable", "CreateTable"], ) - assert "QueryTable" in db._pushdown_operations - assert "CreateTable" in db._pushdown_operations + assert "QueryTable" in db._namespace_client_pushdown_operations + assert "CreateTable" in db._namespace_client_pushdown_operations def test_pushdown_defaults_to_empty(self): """Test that pushdown operations default to empty.""" db = lancedb.connect_namespace("dir", {"root": self.temp_dir}) - assert len(db._pushdown_operations) == 0 + assert len(db._namespace_client_pushdown_operations) == 0 @pytest.mark.asyncio @@ -727,7 +727,7 @@ class TestAsyncPushdownOperations: {"root": self.temp_dir}, namespace_client_pushdown_operations=["QueryTable"], ) - assert "QueryTable" in db._pushdown_operations + assert "QueryTable" in db._namespace_client_pushdown_operations async def test_async_create_table_pushdown_stored(self): """Test that CreateTable pushdown is stored on async connection.""" @@ -736,9 +736,9 @@ class TestAsyncPushdownOperations: {"root": self.temp_dir}, namespace_client_pushdown_operations=["CreateTable"], ) - assert "CreateTable" in db._pushdown_operations + assert "CreateTable" in db._namespace_client_pushdown_operations async def test_async_pushdown_defaults_to_empty(self): """Test that pushdown operations default to empty on async connection.""" db = lancedb.connect_namespace_async("dir", {"root": self.temp_dir}) - assert len(db._pushdown_operations) == 0 + assert len(db._namespace_client_pushdown_operations) == 0