diff --git a/python/python/tests/test_namespace.py b/python/python/tests/test_namespace.py index b3e8fd200..7f20bf459 100644 --- a/python/python/tests/test_namespace.py +++ b/python/python/tests/test_namespace.py @@ -808,6 +808,37 @@ class TestPushdownOperations: db = lancedb.connect_namespace("dir", {"root": self.temp_dir}) assert len(db._namespace_client_pushdown_operations) == 0 + def test_route_pushdown_to_rust_for_native_rest(self): + """A natively-built rest connection must defer QueryTable pushdown to + Rust so reads carry the x-lancedb-min-timestamp read-freshness header.""" + db = lancedb.connect_namespace( + "rest", + {"uri": "http://localhost:12345"}, + namespace_client_pushdown_operations=["QueryTable"], + ) + assert db._route_pushdown_to_rust is True + + def test_route_pushdown_to_rust_false_for_dir(self): + """A non-native (dir) connection keeps the Python pushdown path.""" + db = lancedb.connect_namespace("dir", {"root": self.temp_dir}) + assert db._route_pushdown_to_rust is False + + def test_async_route_pushdown_to_rust_for_native_rest(self): + """The async connection must not silently bypass the read-freshness fix: + a natively-built rest connection defers pushdown to Rust (regression test + for the async path omitting the freshness header).""" + db = lancedb.connect_namespace_async( + "rest", + {"uri": "http://localhost:12345"}, + namespace_client_pushdown_operations=["QueryTable"], + ) + assert db._route_pushdown_to_rust is True + + def test_async_route_pushdown_to_rust_false_for_dir(self): + """The async non-native (dir) connection keeps the Python pushdown path.""" + db = lancedb.connect_namespace_async("dir", {"root": self.temp_dir}) + assert db._route_pushdown_to_rust is False + def test_lance_table_to_arrow_uses_query_pushdown(self): namespace_client = _NamespaceClient() table = _namespace_lance_table(namespace_client)