mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-13 14:16:54 +00:00
Remote SQL failures currently become generic runtime errors, and HTTP table lookup can discard server error metadata. Preserve transport status, current request ID, SQL job ID and worker request ID across Rust and Python. Select typed column, table, reference and schema exceptions only when an explicit server code matches the transport status. Remote `HttpError` and `RuntimeError` handlers remain compatible. Failed SQL jobs retain `JobFailedError` with a typed SQL cause when available. Missing metadata stays absent; message text never determines the exception class. Local missing-column errors retain their type and qualified-field suggestions, and `JobFailure.source` documents structured remote Flight SQL failures. This branch integrates main at `a9ad4997`, including its released Lance 15.0.0-beta.9 dependency update and remote optimize support. The only textual conflict was two independent additions to `test_remote_db.py`; both test groups and all original assertions are retained. The feature has no dependency or lockfile delta against current main. SDK runtime validation on `03ee633a` (runtime source unchanged in `f3f2d0b8`), macOS ARM64, pinned Rust 1.97.0 and the frozen uv Python 3.14 environment: - Rebuilt the native extension from the integrated source. All 22 targeted Python tests passed: native local errors, HTTP/Flight metadata, legacy sync/async table-not-found behavior, and the three main remote-optimize regressions. - All 52 Rust SQL, metadata/source and nested-field tests passed, including the new main optimize cases. - Root and Python-binding Rust Clippy with `-D warnings`, Rust formatting, Python package Ruff and conflict-file formatting passed. - Repository-wide Ruff reports 59 existing documentation findings, and its format check identifies six documentation files. Every affected file is byte-identical to current main; these checks are not reported as passing. - Direct integration review and AST comparison confirm both conflicting test groups were preserved. Earlier exception-constructor/pickling evidence remains applicable to the unchanged Python error modules. The unlocked build exhausted disk again on a runner with the same label but only 9.4 GiB free on a 72 GiB root filesystem. Keep the existing runner and dependency caches, serialize Cargo compilation, and remove only completed test/bench executables reported by Cargo. This job never runs those binaries; normal binaries, libraries and build-script outputs remain available. Fresh resolution, the ci profile, all features, and test/bench compilation and linking are retained. Three probes using Cargo and target-path validation pass with `-D warnings`: all fixture targets link while ordinary outputs remain usable; an undefined symbol still produces Cargo exit 101 and its linker diagnostic; files outside the target directory are never removed. The [current-head build-no-lock job](https://github.com/lancedb/lancedb/actions/runs/41911613851/job/126860364065) passed on `f3f2d0b8`: all compilation/linking completed, 20 completed test executables were removed, and `target` retained about 7.3 GiB. This successful run had a 145 GiB root with about 78 GiB free afterward; it was not an identical rerun of the failed 72 GiB image. The driver tests also passed in this job. All previous-head jobs ended naturally before the push; new-head CI and review gates still apply. Typed remote input exceptions require the server metadata contract. Older servers retain generic transport errors and existing missing-table compatibility. The optimize tests use mock servers and do not establish downstream server acceptance. BREAKING CHANGE: Rust callers with exhaustive matches on `lancedb::Error` must handle the new `FieldNotFound` and `Sql` variants. Local `Error::ColumnNotFound` failures now raise `lancedb.exceptions.ColumnNotFoundError`, a `ValueError` subclass. Python callers that previously caught only `RuntimeError` for this local failure must catch `ColumnNotFoundError` or `ValueError`.
95 lines
2.6 KiB
Python
95 lines
2.6 KiB
Python
# SPDX-License-Identifier: Apache-2.0
|
|
# SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
|
|
"""Custom exception handling"""
|
|
|
|
from typing import Optional
|
|
|
|
|
|
class MissingValueError(ValueError):
|
|
"""Exception raised when a required value is missing."""
|
|
|
|
pass
|
|
|
|
|
|
class MissingColumnError(KeyError):
|
|
"""
|
|
Exception raised when a column name specified is not in
|
|
the DataFrame object
|
|
"""
|
|
|
|
def __init__(self, column_name):
|
|
self.column_name = column_name
|
|
|
|
def __str__(self):
|
|
return (
|
|
f"Error: Column '{self.column_name}' does not exist in the DataFrame object"
|
|
)
|
|
|
|
|
|
class ColumnNotFoundError(ValueError):
|
|
"""A requested table column does not exist.
|
|
|
|
Remote HTTP and SQL errors inherit this type and carry request metadata.
|
|
Locally rejected queries have no request or job identifiers.
|
|
"""
|
|
|
|
def __init__(self, message: str):
|
|
super().__init__(message)
|
|
self.request_id: Optional[str] = None
|
|
self.job_id: Optional[str] = None
|
|
self.job_request_id: Optional[str] = None
|
|
|
|
|
|
class ReferenceNotFoundError(ValueError):
|
|
"""A requested branch or table reference does not exist."""
|
|
|
|
request_id: Optional[str] = None
|
|
job_id: Optional[str] = None
|
|
job_request_id: Optional[str] = None
|
|
|
|
|
|
class SchemaMismatchError(ValueError):
|
|
"""Input data does not match the table's schema."""
|
|
|
|
request_id: Optional[str] = None
|
|
job_id: Optional[str] = None
|
|
job_request_id: Optional[str] = None
|
|
|
|
|
|
class JobFailedError(RuntimeError):
|
|
"""Exception raised when an asynchronous job reaches the failed state.
|
|
|
|
``job_id`` identifies the failed job when available. ``sql_job_id`` preserves
|
|
the SQL execution identity reported by the server, which may differ from
|
|
the outer job's identity. ``request_id`` and ``job_request_id`` identify the
|
|
current request and isolated worker request. A typed SQL cause is available
|
|
through ``__cause__`` when the server reports one.
|
|
"""
|
|
|
|
def __init__(
|
|
self,
|
|
message: str,
|
|
job_id: Optional[str] = None,
|
|
sql_job_id: Optional[str] = None,
|
|
request_id: Optional[str] = None,
|
|
job_request_id: Optional[str] = None,
|
|
):
|
|
super().__init__(message)
|
|
self.job_id = job_id
|
|
self.sql_job_id = sql_job_id
|
|
self.request_id = request_id
|
|
self.job_request_id = job_request_id
|
|
|
|
|
|
class JobCancelledError(RuntimeError):
|
|
"""Exception raised when an asynchronous job was cancelled."""
|
|
|
|
pass
|
|
|
|
|
|
class JobNotFoundError(ValueError):
|
|
"""Exception raised when opening a job the server does not have."""
|
|
|
|
pass
|