mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-26 12:33:59 +00:00
fix(python): surface Function drop warnings (#4880)
Remote Python `drop_function` currently discards the dependent-view warnings returned by SQL DROP. Both the synchronous and coroutine APIs now emit those warnings through `warnings.warn` while preserving their boolean result and executing DROP once. The server support is already merged in lancedb/sophon#9820. The Rust decoder reads warnings across every result batch, including an empty first batch. Missing warning columns remain compatible with older servers; malformed or null warning lists are rejected. The hidden binding bridge carries the warnings to Python. The separate `drop_function_async` API and its `(bool, Job)` contract are unchanged. Python warning filters can raise after the catalog mutation has completed. Validation: a compiled PyO3/public-server reproduction failed before the fix and passed afterward; the public async path also returned `true` with the expected dependent-view warning. Final source passes two focused Rust tests, two Python wrapper tests, strict targeted Clippy, formatting, and Ruff. Three decoder tests cover batch/null/type and older-server behavior. The public runs preceded a two-file simplification of the completed Job projection; focused final-source checks cover that delta. Current-main integration is conflict-free, and its overlapping changes concern independent retry-policy APIs/tests. Documentation now covers warning filters, the post-removal warnings-as-errors behavior, and silent compatibility with older servers. The follow-up changes only prose and a Python docstring; the runtime validation above remains applicable. Refs ENT-3659. Whole-issue independent acceptance remains pending.
This commit is contained in:
@@ -1972,6 +1972,45 @@ def test_sync_catalog_path_preserves_execution_controls():
|
||||
assert _assert_execution_control_encoding(version) == definition
|
||||
|
||||
|
||||
def test_sync_drop_function_emits_server_warnings_without_changing_bool_api():
|
||||
class _DropConnection:
|
||||
async def drop_function(self, name, *, version, namespace_path=None):
|
||||
return True
|
||||
|
||||
async def _drop_function_with_warnings(
|
||||
self, name, *, version, namespace_path=None
|
||||
):
|
||||
return True, [
|
||||
'materialized view "pinned" references Function "embed" version "1"'
|
||||
]
|
||||
|
||||
connection = object.__new__(RemoteDBConnection)
|
||||
connection._conn = _DropConnection()
|
||||
|
||||
with pytest.warns(UserWarning, match="references Function"):
|
||||
assert connection.drop_function("embed", version="1") is True
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_async_drop_function_emits_server_warnings_without_changing_bool_api():
|
||||
class _Inner:
|
||||
async def _drop_function_with_warnings(
|
||||
self, name, version, namespace_path=None
|
||||
):
|
||||
return True, [
|
||||
'materialized view "pinned" references Function "embed" version "1"'
|
||||
]
|
||||
|
||||
async def drop_function(self, name, version, namespace_path=None):
|
||||
return True
|
||||
|
||||
connection = object.__new__(AsyncConnection)
|
||||
connection._inner = _Inner()
|
||||
|
||||
with pytest.warns(UserWarning, match="references Function"):
|
||||
assert await connection.drop_function("embed", version="1") is True
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def _mock_remote_function_catalog():
|
||||
state = {"requests": [], "version": None}
|
||||
|
||||
Reference in New Issue
Block a user