From c278f90cc196784b3a0921f1046e51c30bffaa93 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Tue, 17 Nov 2026 13:31:32 +0800 Subject: [PATCH 1/5] feat: expose shared Arrow type golden behind test-fixtures (#5065) Downstream compatibility tests currently load the Function Arrow type golden from a LanceDB source checkout. Add a default-off `test-fixtures` feature that exposes `lancedb::test_fixtures::FUNCTION_ARROW_TYPES_JSON`, so consumers can enable it on their existing LanceDB dev-dependency and use the golden from the same revision. The golden stays in its existing location with unchanged bytes. LanceDB's Rust test reads the exported constant; Python tests and release/versioning workflows remain unchanged. --- rust/lancedb/Cargo.toml | 2 ++ rust/lancedb/src/lib.rs | 4 ++++ rust/lancedb/src/table/computed_columns.rs | 6 ++---- rust/lancedb/src/test_fixtures.rs | 21 +++++++++++++++++++++ 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 rust/lancedb/src/test_fixtures.rs diff --git a/rust/lancedb/Cargo.toml b/rust/lancedb/Cargo.toml index cdc575e69..34e91dbfd 100644 --- a/rust/lancedb/Cargo.toml +++ b/rust/lancedb/Cargo.toml @@ -140,6 +140,8 @@ pprof = { version = "0.14", features = ["flamegraph"] } [features] default = [] +# Shared golden data for downstream compatibility tests. +test-fixtures = [] # Local SQL computed columns and materialized-view creation/refresh. # Remote clients and shared server primitives do not require this feature. experimental-functions = [] diff --git a/rust/lancedb/src/lib.rs b/rust/lancedb/src/lib.rs index 9f800d593..de555f709 100644 --- a/rust/lancedb/src/lib.rs +++ b/rust/lancedb/src/lib.rs @@ -48,6 +48,8 @@ //! Install any `metrics`-compatible recorder to collect them. //! - `metrics-otel` - Add a pull-based adapter (the `metrics_otel` module) over //! the `metrics` facade for bridging metrics into OpenTelemetry or similar. +//! - `test-fixtures` - Expose shared golden data through `test_fixtures` for +//! downstream compatibility tests. Disabled by default. //! //! ### Quick Start //! @@ -220,6 +222,8 @@ pub mod server_info; pub mod sql; pub mod storage_integration; pub mod table; +#[cfg(any(test, feature = "test-fixtures"))] +pub mod test_fixtures; #[cfg(test)] pub mod test_utils; pub mod utils; diff --git a/rust/lancedb/src/table/computed_columns.rs b/rust/lancedb/src/table/computed_columns.rs index 7348e659d..a87c38f3c 100644 --- a/rust/lancedb/src/table/computed_columns.rs +++ b/rust/lancedb/src/table/computed_columns.rs @@ -2906,10 +2906,8 @@ mod tests { #[test] fn output_arrow_type_grammar_matches_the_shared_golden() { - let golden: serde_json::Value = serde_json::from_str(include_str!( - "../../tests/fixtures/first_class_functions/v1/arrow_types.json" - )) - .unwrap(); + let golden: serde_json::Value = + serde_json::from_str(crate::test_fixtures::FUNCTION_ARROW_TYPES_JSON).unwrap(); let valid = golden["valid"].as_array().unwrap().iter(); for case in valid.chain(golden["server_only"].as_array().unwrap()) { let raw = case["arrow_type"].as_str().unwrap(); diff --git a/rust/lancedb/src/test_fixtures.rs b/rust/lancedb/src/test_fixtures.rs new file mode 100644 index 000000000..71ea8c6e8 --- /dev/null +++ b/rust/lancedb/src/test_fixtures.rs @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright The LanceDB Authors + +//! Shared golden data for downstream compatibility tests. +//! +//! Enable the `test-fixtures` feature to access these fixtures from another crate. + +/// The version 1 Function Arrow type golden as UTF-8 JSON. +/// +/// Contains supported declaration spellings, their canonical JSON Arrow types, +/// and declarations that must be rejected. The contents match the golden used by +/// LanceDB's Rust and Python tests; parsing is left to the consumer. +/// +/// ``` +/// let golden: serde_json::Value = +/// serde_json::from_str(lancedb::test_fixtures::FUNCTION_ARROW_TYPES_JSON).unwrap(); +/// assert!(golden["valid"].is_array()); +/// assert!(golden["invalid"].is_array()); +/// ``` +pub const FUNCTION_ARROW_TYPES_JSON: &str = + include_str!("../tests/fixtures/first_class_functions/v1/arrow_types.json"); From ff9dc7a2bed199176dfeb3cb19b675a38328e7ed Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Tue, 17 Nov 2026 13:48:13 +0800 Subject: [PATCH 2/5] feat(function): expose descriptor refresh plan in terminal result (#5064) ## Summary Add the terminal plan shape for Function-backed refresh results: - `FunctionRefreshPlan` describes the descriptor-derived size tiers, selected worker classes, batch bytes, row counts, and batch counts. - `FunctionRefreshTier` describes one byte-bounded tier. - `RefreshColumnResult.plan` carries the plan in the public terminal result, optional and omitted when absent. This is the SDK prerequisite for descriptor-first Function refresh planning. It only exposes the shared result shape; it does not compute the plan or change refresh execution. ## Compatibility Existing terminal payloads and callers are unchanged: the new field is `#[serde(default, skip_serializing_if = "Option::is_none")]`, so absent plans stay absent and old payloads decode to `None`. ## Validation - `git diff --check` - Unit tests cover absent-plan serialization and plan round-trip. - Repository CI on this PR. --- rust/lancedb/src/function.rs | 86 +++++++++++++++++++++++++++++++ rust/lancedb/src/table/refresh.rs | 1 + 2 files changed, 87 insertions(+) diff --git a/rust/lancedb/src/function.rs b/rust/lancedb/src/function.rs index d0ef6570d..4e7157c37 100644 --- a/rust/lancedb/src/function.rs +++ b/rust/lancedb/src/function.rs @@ -1261,6 +1261,46 @@ impl FunctionBinding { } } +/// One byte-bounded size tier of a Function refresh plan. +/// +/// A row belongs to the first tier whose `max_row_bytes` admits its total +/// descriptor payload size. The final tier has no upper bound and carries the +/// largest configured worker class. +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub struct FunctionRefreshTier { + /// Inclusive upper bound of the rows this tier admits. `None` on the last + /// tier, which also serves rows larger than every configured class. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub max_row_bytes: Option, + /// Worker resource class selected for this tier. + pub worker_class: String, + /// Worker container memory limit for `worker_class`. + pub worker_memory_bytes: u64, + /// Logical UDF executor budget derived from the worker limit. + pub executor_budget_bytes: u64, + /// Byte target for one materialized Blob input batch on this tier. + pub batch_bytes: u64, + /// Rows assigned to this tier. + pub rows: u64, + /// Byte-bounded batches the assigned rows form at `batch_bytes`. + pub batches: u64, +} + +/// Descriptor-derived tier plan for one Function refresh. +/// +/// The plan is computed from Blob descriptor sizes before any payload read. It +/// names the same worker classes the refresh supervisor uses for routing. +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub struct FunctionRefreshPlan { + /// Worker class the supervisor starts ordinary work on. + pub default_worker_class: String, + /// Row cap supplied through the `batch_size` override, when present. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub batch_size: Option, + /// Tiers ordered from the smallest to the largest worker class. + pub tiers: Vec, +} + /// Stable terminal result of an expression-backed or Function-backed column /// refresh [`crate::Job`]. /// @@ -1279,6 +1319,10 @@ pub struct RefreshColumnResult { /// Table version made visible by the refresh, when one was published. #[serde(default, skip_serializing_if = "Option::is_none")] pub published_version: Option, + /// Descriptor-derived tier plan, when the refresh is Function-backed and + /// its inputs expose Blob descriptor sizes. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub plan: Option, } /// Which per-row errors [`crate::Table::function_errors`] lists. Every @@ -1409,6 +1453,48 @@ impl RefreshColumnResult { impl_json!(RefreshColumnResult); +#[cfg(test)] +mod refresh_result_tests { + use super::{FunctionRefreshPlan, FunctionRefreshTier, RefreshColumnResult}; + + fn result(plan: Option) -> RefreshColumnResult { + RefreshColumnResult { + rows_assigned: 3, + rows_failed: 0, + rows_remaining: 0, + source_version: 7, + published_version: Some(8), + plan, + } + } + + #[test] + fn absent_plan_stays_out_of_the_terminal_payload() { + let encoded = serde_json::to_value(result(None)).unwrap(); + assert!(encoded.get("plan").is_none()); + } + + #[test] + fn descriptor_plan_round_trips_through_the_terminal_payload() { + let plan = FunctionRefreshPlan { + default_worker_class: "medium".to_string(), + batch_size: Some(1), + tiers: vec![FunctionRefreshTier { + max_row_bytes: None, + worker_class: "large".to_string(), + worker_memory_bytes: 16 << 30, + executor_budget_bytes: 11 << 30, + batch_bytes: 1 << 20, + rows: 3, + batches: 2, + }], + }; + let encoded = serde_json::to_value(result(Some(plan.clone()))).unwrap(); + let decoded: RefreshColumnResult = serde_json::from_value(encoded).unwrap(); + assert_eq!(decoded.plan, Some(plan)); + } +} + #[cfg(test)] mod conda_environment_tests { use super::{PythonEnvironmentSpec, PythonRuntimeSpec}; diff --git a/rust/lancedb/src/table/refresh.rs b/rust/lancedb/src/table/refresh.rs index f38509002..879527f24 100644 --- a/rust/lancedb/src/table/refresh.rs +++ b/rust/lancedb/src/table/refresh.rs @@ -782,6 +782,7 @@ pub(crate) async fn execute_refresh_column_async( rows_remaining: 0, source_version: execution.source_version, published_version: execution.published_version, + plan: None, }) }))) } From e61252f4dc99dc90c13f1f25a50a180056157b22 Mon Sep 17 00:00:00 2001 From: Jack Ye Date: Tue, 17 Nov 2026 00:10:59 -0800 Subject: [PATCH 3/5] feat(python): capture Arrow and structured Function globals (#5044) Function source packaging inlined only scalar literals and tuples of them. A module-level PyArrow type shared by `output_schema=` and the Function body, a label map, or a small NumPy weight vector failed at decoration with an "unsupported global value" error and had to be redefined inside the body. These globals are now captured: ```python import numpy as np import pyarrow as pa from lancedb import function OUT_TYPE = pa.struct([pa.field("label", pa.string()), pa.field("score", pa.int32())]) LABELS = {"pick": 0, "place": 1} WEIGHTS = np.array([0.25, 0.75]) @function( input_schema=pa.schema([pa.field("x", pa.int64(), nullable=False)]), output_schema=pa.field("out", OUT_TYPE, nullable=False), pip=["numpy"], ) def judge(x: pa.Array) -> pa.Array: score = int(WEIGHTS.sum() * 10) rows = [{"label": "pick", "score": LABELS["pick"] + score}] * len(x) return pa.array(rows, type=OUT_TYPE) ``` | Captured global | Rebuilt in the artifact as | | --- | --- | | `None`, `bool`, `int`, `str`, `bytes`, finite `float` | a literal (unchanged) | | tuple, list, dict, set, frozenset of supported values | a literal; dicts keep insertion order, set elements are sorted by their source | | PyArrow `DataType`, `Field`, `Schema` | `pa.ipc.read_schema` over the value's IPC schema bytes, which keeps nullability, metadata, and nested fields | | NumPy array or scalar of a bool, integer, float16, float32, or float64 dtype | `np.array(, dtype=)` or `np.dtype().type()` | - Each value is a copy taken when the decorator runs and rebuilt per worker process, so values that share an object become separate copies. Packaging does not depend on hash randomization. - Each value is limited to 1 MiB of source and 32 levels of nesting. Cycles and Python-defined Arrow extension types are rejected. The size limit also applies to the existing literal captures. - Unsupported values keep the error that names the global, its type, the supported captures, and the remedy. - `pyarrow` and `numpy` are imported under private aliases ahead of the captured globals. The builtins used for empty sets and frozensets are claimed, so a module that rebinds them fails packaging instead of silently shadowing them. Empty NumPy arrays are encoded directly from dtype and shape, so even `(500_000, 0)` stays compact without expanding nested Python lists. --- docs/src/python/python.md | 35 ++- python/python/lancedb/functions.py | 237 ++++++++++++++-- .../python/tests/test_function_packaging.py | 267 +++++++++++++++++- 3 files changed, 502 insertions(+), 37 deletions(-) diff --git a/docs/src/python/python.md b/docs/src/python/python.md index b0425e1f7..b64940e39 100644 --- a/docs/src/python/python.md +++ b/docs/src/python/python.md @@ -517,11 +517,36 @@ def probe_library(name: str) -> str: return native_diagnostics.find_library(name) ``` -Captured literal globals support `None`, booleans, integers, strings, bytes, -finite floats, and tuples of these values. Construct other objects, including -PyArrow types and schemas, inside the Function or helper module instead. Values -used only in the decorator's `input_schema` or `output_schema` are not captured -globals and can be defined outside the Function. +Captured globals are copied into the Function's source. They can be `None`, +booleans, integers, strings, bytes, and finite floats; tuples, lists, dicts, +sets, and frozensets of supported values; PyArrow data types, fields, and +schemas; and NumPy arrays and scalars of bool, integer, `float16`, `float32`, +and `float64` dtypes. The copy is taken when the decorator runs and rebuilt in +each worker process, so later changes on either side are not shared. NumPy +values need `numpy` in the remote environment; declare it with `pip=` or +`conda=`. Each value is limited to 1 MiB of source and 32 levels of nesting; +load larger data inside the Function, for example from a table or a package +resource shipped with `code=`. Construct other objects inside the Function or +helper module instead. Values used only in the decorator's `input_schema` or +`output_schema` are not captured globals and can be defined outside the +Function. + +```python +import pyarrow as pa +from lancedb import function + +LABELS = {"pick": 0, "place": 1} +RESULT = pa.struct([pa.field("label", pa.string()), pa.field("id", pa.int32())]) + + +@function( + input_schema=pa.schema([pa.field("action", pa.string(), nullable=False)]), + output_schema=pa.field("result", RESULT, nullable=False), +) +def label(action: pa.Array) -> pa.Array: + rows = [{"label": name, "id": LABELS[name]} for name in action.to_pylist()] + return pa.array(rows, type=RESULT) +``` Annotate a blob input with `lancedb.BlobReader` for lazy, seekable access, or with `bytes` to materialize its contents before the Function runs. Reader diff --git a/python/python/lancedb/functions.py b/python/python/lancedb/functions.py index f57a114dc..9178d5194 100644 --- a/python/python/lancedb/functions.py +++ b/python/python/lancedb/functions.py @@ -1859,24 +1859,42 @@ def _is_function_decorator(node: ast.expr) -> bool: ) -def _literal_source(value: Any, name: str) -> str: - if value is None or type(value) in (bool, int, str, bytes): - return repr(value) - if type(value) is float and math.isfinite(value): - return repr(value) - if type(value) is tuple: - children = ", ".join(_literal_source(child, name) for child in value) - if len(value) == 1: - children += "," - return f"({children})" - raise TypeError( +# A captured value is inlined into the artifact source; larger data belongs in a +# table or a package resource. +_MAX_CAPTURED_SOURCE = 1024 * 1024 +# Far below CPython's parser nesting limit. +_MAX_CAPTURED_DEPTH = 32 +_CAPTURE_REMEDY = "Define this value inside the function or class body instead." + + +def _unsupported_capture(name: str, kind: str) -> TypeError: + return TypeError( "Function source references an unsupported global value of type " - f"{type(value).__name__} in {name!r}. Only None, bool, int, str, bytes, " - "finite float, and tuples of these literals can be captured. " - "Define this value inside the function or class body instead." + f"{kind} in {name!r}. Captured globals can be None, bool, int, str, " + "bytes, or finite float values; tuples, lists, dicts, sets, or frozensets " + "of supported values; PyArrow data types, fields, or schemas; or NumPy " + "arrays or scalars of bool, integer, float16, float32, or float64 dtypes. " + + _CAPTURE_REMEDY ) +def _python_extension_type(data_type: pa.DataType) -> Optional[pa.ExtensionType]: + """The first extension type within `data_type` whose class is defined in + Python. IPC carries only its name, so it deserializes as the storage type + wherever that class is not registered.""" + if isinstance(data_type, pa.ExtensionType): + return data_type + if isinstance(data_type, pa.BaseExtensionType): + return _python_extension_type(data_type.storage_type) + if isinstance(data_type, pa.DictionaryType): + return _python_extension_type(data_type.value_type) + for index in range(data_type.num_fields): + found = _python_extension_type(data_type.field(index).type) + if found is not None: + return found + return None + + _DYNAMIC_NAMESPACE_ACCESS = frozenset( {"globals", "locals", "vars", "eval", "exec", "compile", "__import__"} ) @@ -2175,7 +2193,7 @@ class _SourcePackager: The module holds the definition plus exactly the module-level names it references: modules as imports, importable classes and functions as - imports, literals inline, and functions and classes defined in + imports, captured values inline, and functions and classes defined in ``__main__`` by source, recursively, dependencies first. """ @@ -2183,6 +2201,7 @@ class _SourcePackager: self._code_modules = code_modules self._requirements = requirements self._imports: dict[str, str] = {} + self._support_imports: dict[str, str] = {} self._definitions: list[str] = [] self._packaged: set[int] = set() self._names: dict[str, Any] = {} @@ -2191,8 +2210,13 @@ class _SourcePackager: def package(self, target: Any, signature: FunctionSignature) -> str: entry = self._definition(target, entry=True, signature=signature) parts = [_SOURCE_HEADER] - if self._imports: - parts.extend(["", *(self._imports[name] for name in sorted(self._imports))]) + # Captured values are rebuilt with the support modules, so those come first. + imports = [ + *(self._support_imports[alias] for alias in sorted(self._support_imports)), + *(self._imports[name] for name in sorted(self._imports)), + ] + if imports: + parts.extend(["", *imports]) for definition in self._definitions: parts.extend(["", definition]) parts.extend(["", entry, ""]) @@ -2313,8 +2337,8 @@ class _SourcePackager: def _global_source(self, name: str, value: Any) -> str: """One module-level line that rebinds `name` to `value` in the artifact: - an import for modules and importable classes/functions, a literal - otherwise.""" + an import for modules and importable classes/functions, a captured + copy otherwise.""" if value is BlobReader: return f"from lance_blob import BlobReader as {name}" if isinstance(value, types.ModuleType): @@ -2347,7 +2371,149 @@ class _SourcePackager: if imported is value: self._require_importable(module_name) return f"from {module_name} import {qualname} as {name}" - return f"{name} = {_literal_source(value, name)}" + return f"{name} = {self._captured_source(name, value)}" + + def _captured_source(self, name: str, value: Any) -> str: + """An expression that rebuilds a copy of the global `name`. + + Literals and containers are written as Python literals, with set + elements sorted by their source so the artifact does not depend on hash + randomization. Arrow values are rebuilt from Arrow's IPC schema encoding + and NumPy values from their dtype and elements. + """ + remaining = _MAX_CAPTURED_SOURCE + enclosing: set[int] = set() + + def too_large() -> ValueError: + return ValueError( + f"Function global {name!r} is too large to capture: its source " + f"exceeds {_MAX_CAPTURED_SOURCE} characters. Load large data inside " + "the function or class body instead, for example from a table or a " + "package resource shipped with code=." + ) + + def charge(source: str, nested: Sequence[str] = ()) -> str: + nonlocal remaining + remaining -= len(source) - sum(map(len, nested)) + if remaining < 0: + raise too_large() + return source + + def emit(value: Any) -> str: + if value is None or type(value) in (bool, int, str, bytes): + return charge(repr(value)) + if type(value) is float and math.isfinite(value): + return charge(repr(value)) + if isinstance(value, (pa.DataType, pa.Field, pa.Schema)): + return charge(self._arrow_source(name, value)) + numpy = sys.modules.get("numpy") + if numpy is not None and ( + type(value) is numpy.ndarray or isinstance(value, numpy.generic) + ): + return emit_numpy(numpy, value) + if type(value) in (tuple, list, dict, set, frozenset): + return emit_container(value) + raise _unsupported_capture(name, type(value).__name__) + + def emit_numpy(numpy: types.ModuleType, value: Any) -> str: + # These convert to exact Python values; longdouble stays a NumPy scalar. + if value.dtype.kind not in "biuf" or value.dtype.type is numpy.longdouble: + raise _unsupported_capture( + name, f"{type(value).__name__} with dtype {value.dtype}" + ) + # Every element takes at least one character; check before tolist(). + if value.size > remaining: + raise too_large() + alias = self._support_module("numpy") + dtype = repr(value.dtype.str) + if isinstance(value, numpy.generic): + item = emit(value.item()) + return charge(f"{alias}.dtype({dtype}).type({item})", (item,)) + if value.size == 0: + return charge( + f"{alias}.array([], dtype={dtype}).reshape({value.shape!r})" + ) + elements = emit(value.tolist()) + source = f"{alias}.array({elements}, dtype={dtype})" + return charge(source, (elements,)) + + def emit_container(value: Any) -> str: + if id(value) in enclosing: + raise ValueError( + f"Function global {name!r} contains itself and cannot be " + "captured. " + _CAPTURE_REMEDY + ) + if len(enclosing) == _MAX_CAPTURED_DEPTH: + raise ValueError( + f"Function global {name!r} nests containers more than " + f"{_MAX_CAPTURED_DEPTH} levels deep and cannot be captured. " + + _CAPTURE_REMEDY + ) + enclosing.add(id(value)) + if type(value) is dict: + entries = [(emit(key), emit(child)) for key, child in value.items()] + children = [part for entry in entries for part in entry] + listed = ", ".join(f"{key}: {child}" for key, child in entries) + source = f"{{{listed}}}" + else: + children = [emit(child) for child in value] + if type(value) in (set, frozenset): + listed = ", ".join(sorted(children)) + else: + listed = ", ".join(children) + if type(value) is tuple: + source = f"({listed},)" if len(children) == 1 else f"({listed})" + elif type(value) is list: + source = f"[{listed}]" + elif type(value) is set: + source = ( + f"{{{listed}}}" if children else f"{self._builtin('set')}()" + ) + else: + items = f"{{{listed}}}" if children else "" + source = f"{self._builtin('frozenset')}({items})" + enclosing.remove(id(value)) + return charge(source, children) + + return emit(value) + + def _arrow_source( + self, name: str, value: Union[pa.DataType, pa.Field, pa.Schema] + ) -> str: + if isinstance(value, pa.Schema): + schema, suffix = value, "" + elif isinstance(value, pa.Field): + schema, suffix = pa.schema([value]), ".field(0)" + else: + schema, suffix = pa.schema([pa.field("", value)]), ".field(0).type" + for data_type in schema.types: + extension = _python_extension_type(data_type) + if extension is not None: + raise TypeError( + f"Function global {name!r} uses the Arrow extension type " + f"{extension.extension_name!r}, which is defined in Python and " + "cannot be captured. " + _CAPTURE_REMEDY + ) + alias = self._support_module("pyarrow") + # Schema IPC keeps nullability, metadata, and nested fields exactly. + data = schema.serialize().to_pybytes() + return f"{alias}.ipc.read_schema({alias}.py_buffer({data!r})){suffix}" + + def _support_module(self, module: str) -> str: + """The artifact's private alias for a module that rebuilds captured + values.""" + alias = f"_lancedb_{module}" + if alias not in self._support_imports: + self._require_importable(module) + self._claim(alias, ("support", module)) + self._support_imports[alias] = f"import {module} as {alias}" + return alias + + def _builtin(self, name: str) -> str: + """A builtin called by captured source, which the artifact must not + rebind.""" + self._claim(name, ("builtin", name)) + return name def _require_importable(self, module_name: str) -> None: """Warn about an import the Function's environment may not be able to @@ -3015,8 +3181,11 @@ def function( - modules, and classes and functions importable from an installed package, become imports; the package must be declared in ``pip`` or ``conda``; - - literals (``None``, ``bool``, ``int``, ``str``, ``bytes``, finite - ``float``, and tuples containing only these literals) are inlined; + - values are copied into the source: ``None``, ``bool``, ``int``, + ``str``, ``bytes``, and finite ``float``; tuples, lists, dicts, sets, + and frozensets of supported values; PyArrow data types, fields, and + schemas; and NumPy arrays and scalars of ``bool``, integer, + ``float16``, ``float32``, and ``float64`` dtypes; - functions and classes defined in ``__main__``, such as notebook cells, are packaged by source, together with what they reference; - modules and packages listed in ``code`` are shipped as Python source and @@ -3034,13 +3203,27 @@ def function( image. Warnings follow normal Python warning filters and may be promoted to errors. Declare every third-party import in ``pip`` or ``conda`` even when it happens to be installed on the registration host. - Other global values, including Arrow types and schemas, lists, dictionaries, - sets, and NumPy arrays, cannot be captured as literals. Define them inside - the function or class body instead. - Closures, lambdas, nested definitions, mutable module-level objects, and a - non-standard ``__builtins__`` are rejected where they can be seen and + Closures, lambdas, nested definitions, other mutable module-level objects, + and a non-standard ``__builtins__`` are rejected where they can be seen and otherwise unsupported. + **Captured values.** A captured value is copied when the decorator runs + and rebuilt in every worker process. Later changes on the client do not + reach the Function, changes a worker makes stay in that process, and + globals that share an object on the client become separate copies. + Dictionaries keep their insertion order and set elements are written in a + canonical order, so the same values always package to the same source. + Floats, including NumPy elements, must be finite. Arrow values are rebuilt + from Arrow's IPC schema encoding, which preserves nullability, metadata, + and nested fields; extension types defined in Python cannot be captured. + NumPy values keep their dtype and shape and need ``numpy`` in the remote + environment, so declare it in ``pip`` or ``conda``. Each captured value is + limited to 1 MiB of source and 32 levels of nesting, and cannot contain + itself. Load larger data inside the function or class body, for example + from a table or a package resource shipped with ``code``. Define other + values, such as instances of your own classes, inside the function or + class body as well. + **Namespace restrictions.** The packaged source cannot import ``sys``, ``builtins``, ``importlib``, ``inspect``, ``gc``, ``ctypes``, or ``types``, including submodules such as ``ctypes.util`` and ``importlib.metadata``. diff --git a/python/python/tests/test_function_packaging.py b/python/python/tests/test_function_packaging.py index fcefc9110..ae74cc8cd 100644 --- a/python/python/tests/test_function_packaging.py +++ b/python/python/tests/test_function_packaging.py @@ -9,6 +9,7 @@ import base64 import importlib import hashlib import json +import os import subprocess import sys import textwrap @@ -17,6 +18,7 @@ import warnings from pathlib import Path from typing import Annotated, Optional, get_type_hints +import numpy as np import pyarrow as pa import pytest @@ -234,10 +236,15 @@ def test_function_can_return_a_list_from_a_generator_expression(): @pytest.mark.parametrize( ("global_value", "value_type"), [ - ("pa.struct([('label', pa.string())])", "StructType"), - ("(1, (pa.int64(),))", "DataType"), - ("{'label': 1}", "dict"), ("float('inf')", "float"), + ("{'label': float('nan')}", "float"), + ("[1, (2, object())]", "object"), + ("{'labels': range(2)}", "range"), + ("pa.array([1])", "Int64Array"), + ("np.array(['label'])", "ndarray with dtype pa.Array:\n" + + textwrap.indent(body, " ") + if kind == "class" + else "def judge(x: pa.Array) -> pa.Array:\n" + body + ) + module = helper_package( + "fx_structured_global", + { + "__init__.py": textwrap.dedent(""" + import numpy as np + import pyarrow as pa + + OUT_TYPE = pa.struct( + [pa.field("label", pa.string()), pa.field("score", pa.int32())] + ) + LABELS = { + "pick": 0, + "place": 1, + "nested": [None, (1.5, b"x"), {"deep": frozenset({"b", "a"})}], + } + EMPTY = ([], {}, set(), frozenset(), ()) + ARROW = { + "field": pa.field( + "score", pa.int32(), nullable=False, metadata={"unit": "pts"} + ), + "schema": pa.schema( + [pa.field("label", pa.dictionary(pa.int8(), pa.utf8(), True))], + metadata={"version": "1"}, + ), + "tensor": pa.fixed_shape_tensor(pa.float32(), [2, 2]), + } + WEIGHTS = np.array([[0.1, 0.2], [0.3, 0.4]], dtype=np.float32) + NUMPY = ( + np.float32(0.5), + np.True_, + np.uint64(2**64 - 1), + np.array(1.5), + np.zeros((0, 3), dtype=np.int16), + np.array([1.0, -0.0], dtype=">f8"), + ) + """) + + definition + }, + ) + out_type = module.OUT_TYPE + packaged = function( + input_schema=pa.schema([pa.field("x", pa.int64(), nullable=False)]), + output_schema=pa.field("out", out_type, nullable=False), + )(module.judge) + source = artifact(packaged).decode() + assert "import numpy as _lancedb_numpy" in source + assert "import pyarrow as _lancedb_pyarrow" in source + + namespace = {} + exec(compile(source, "user_function.py", "exec"), namespace) + call = namespace["judge"]() if kind == "class" else namespace["judge"] + result = call(pa.array([1, 2])) + assert result.type == out_type + assert result.to_pylist() == [{"label": "pick", "score": 0}] * 2 + assert namespace["OUT_TYPE"] == out_type + + assert namespace["LABELS"] == module.LABELS + assert list(namespace["LABELS"]) == list(module.LABELS) + assert namespace["EMPTY"] == module.EMPTY + assert [type(value) for value in namespace["EMPTY"]] == [ + type(value) for value in module.EMPTY + ] + for key, value in module.ARROW.items(): + assert namespace["ARROW"][key].equals(value, check_metadata=True) + assert type(namespace["ARROW"][key]) is type(value) + + weights = namespace["WEIGHTS"] + assert weights.dtype == module.WEIGHTS.dtype + assert np.array_equal(weights, module.WEIGHTS) + for captured, original in zip(namespace["NUMPY"], module.NUMPY, strict=True): + assert type(captured) is type(original) + assert captured.dtype == original.dtype + assert np.shape(captured) == np.shape(original) + assert np.array_equal(captured, original) + assert np.signbit(namespace["NUMPY"][-1][1]) + + +@pytest.mark.parametrize("kind", ["function", "class"]) +@pytest.mark.parametrize("shape", [(0,), (0, 3), (2, 0, 3), (500_000, 0)]) +def test_empty_numpy_captures_preserve_shape_without_expanding( + helper_package, kind, shape +): + definition = ( + "class empty_size:\n def __call__(self, value: int) -> int:\n" + " return value + EMPTY.size\n" + if kind == "class" + else "def empty_size(value: int) -> int:\n return value + EMPTY.size\n" + ) + module = helper_package( + "fx_empty_numpy_global", + { + "__init__.py": "import numpy as np\n" + f"EMPTY = np.empty({shape!r}, dtype='>i2')\n" + definition + }, + ) + source = artifact(function(module.empty_size)) + assert len(source) < 1024 + namespace = {} + exec(compile(source, "user_function.py", "exec"), namespace) + captured = namespace["EMPTY"] + assert captured.shape == shape + assert captured.dtype == module.EMPTY.dtype + assert captured.size == 0 + call = namespace["empty_size"]() if kind == "class" else namespace["empty_size"] + assert call(7) == 7 + + +def test_captured_containers_are_copied_when_decorated(helper_package): + module = helper_package( + "fx_captured_copy", + { + "__init__.py": """ + SHARED = [1, 2] + CONFIG = {"shared": SHARED, "again": SHARED} + + def uses_config(value: int) -> int: + return value + len(CONFIG["shared"]) + len(SHARED) + """ + }, + ) + definition = function(module.uses_config) + module.SHARED.append(3) + + namespace = {} + exec(compile(artifact(definition), "user_function.py", "exec"), namespace) + assert namespace["SHARED"] == [1, 2] + assert namespace["CONFIG"] == {"shared": [1, 2], "again": [1, 2]} + assert namespace["CONFIG"]["shared"] is not namespace["CONFIG"]["again"] + assert namespace["CONFIG"]["shared"] is not namespace["SHARED"] + assert namespace["uses_config"](1) == 5 + + +def test_captured_sets_package_deterministically(tmp_path): + script = tmp_path / "sets.py" + script.write_text( + textwrap.dedent( + """ + import json + + from lancedb import function + + WORDS = {f"word{index}" for index in range(20)} + MIXED = frozenset({("pair", 1), b"bytes", None, 2.5, "text"}) + + @function + def known(word: str) -> bool: + return word in WORDS or word in MIXED + + print(json.dumps([ + known.registration_request.artifact.digest, + list(WORDS), + ])) + """ + ) + ) + runs = [] + for seed in ("0", "1", "2", "3"): + result = subprocess.run( + [sys.executable, str(script)], + capture_output=True, + text=True, + env={**os.environ, "PYTHONHASHSEED": seed}, + ) + assert result.returncode == 0, result.stderr + runs.append(json.loads(result.stdout)) + # Hash randomization reorders the client's set; the artifact must not change. + assert len({tuple(order) for _, order in runs}) > 1 + assert len({digest for digest, _ in runs}) == 1 + + +@pytest.mark.parametrize( + ("global_value", "message"), + [ + ("list(range(300_000))", "too large to capture"), + ("np.zeros(2_000_000)", "too large to capture"), + ("'x' * (1024 * 1024)", "too large to capture"), + ("functools.reduce(lambda inner, _: [inner], range(40), [])", "32 levels"), + ("_cycle()", "contains itself"), + ("pa.schema([pa.field('x', pa.list_(_Extension()))])", "defined in Python"), + ], +) +def test_captured_value_limits_name_the_global(helper_package, global_value, message): + module = helper_package( + "fx_captured_limits", + { + "__init__.py": textwrap.dedent(""" + import functools + + import numpy as np + import pyarrow as pa + + class _Extension(pa.ExtensionType): + def __init__(self): + super().__init__(pa.int64(), "fx.extension") + + def __arrow_ext_serialize__(self): + return b"" + + @classmethod + def __arrow_ext_deserialize__(cls, storage_type, serialized): + return cls() + + def _cycle(): + value = [] + value.append(value) + return value + """) + + f"CAPTURED_VALUE = {global_value}\n" + "def uses_global(value: int) -> int:\n" + " return value if CAPTURED_VALUE else 0\n" + }, + ) + with pytest.raises((TypeError, ValueError)) as error: + function(module.uses_global) + assert "CAPTURED_VALUE" in str(error.value) + assert message in str(error.value) + assert "inside the function or class body" in str(error.value) + + +def test_captured_sets_keep_their_builtins(helper_package): + module = helper_package( + "fx_captured_builtins", + { + "__init__.py": """ + STOP = frozenset({"a"}) + frozenset = ("shadowed",) + + def uses_sets(word: str) -> bool: + return word in STOP or word in frozenset + """ + }, + ) + with pytest.raises(ValueError, match="cannot package 'frozenset'"): + function(module.uses_sets) + + @pytest.mark.parametrize("annotation", ["Array", "RecordBatch"]) @pytest.mark.parametrize("kind", ["function", "class"]) def test_batch_annotations_require_explicit_schemas(annotation, kind, helper_package): From 1a216989063a07f1fed003c6dcfd46a351662bc3 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Tue, 17 Nov 2026 16:55:26 +0800 Subject: [PATCH 4/5] chore: update lance dependency to v15.0.0-beta.25 (#5069) Update the Rust workspace, Java core dependency and Python test dependency to [Lance v15.0.0-beta.25](https://github.com/lance-format/lance/releases/tag/v15.0.0-beta.25). Mark computed-column refresh replacements as data changes using Lance's new explicit flag so refreshed values retain the existing index invalidation and row-update behavior. Rust API compatibility: the re-exported `CompactionOptions` adds `max_data_files_per_fragment` and `scope`. Callers using exhaustive struct literals must include the new fields or use `..Default::default()`. Configure macOS Rust tests with an explicit Python 3.13 interpreter and runner/Python-specific caches so doctests do not link against an absent Python framework. --- .github/workflows/rust.yml | 7 +++ Cargo.lock | 96 +++++++++++++++---------------- Cargo.toml | 30 +++++----- java/pom.xml | 2 +- python/pyproject.toml | 2 +- python/uv.lock | 18 +++--- rust/lancedb/src/table/refresh.rs | 5 +- 7 files changed, 85 insertions(+), 75 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9bbc4d581..636c1a7bf 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -311,10 +311,16 @@ jobs: with: fetch-depth: 0 lfs: true + - uses: actions/setup-python@v6 + id: python + with: + python-version: "3.13" - name: CPU features run: sysctl -a | grep cpu - uses: Swatinem/rust-cache@v2 with: + # PyO3 caches the interpreter library path; runner images can differ. + key: ${{ matrix.mac-runner }}-python-${{ steps.python.outputs.python-version }} # Restore everywhere, but only save from main. Per-PR saves are # unreadable outside their own branch anyway, since GitHub scopes # caches to the creating ref. @@ -323,6 +329,7 @@ jobs: run: brew install protobuf - name: Run tests env: + PYO3_PYTHON: ${{ steps.python.outputs.python-path }} CARGO_TEST_TARGETS: ${{ matrix.phase == 'doc' && '--doc' || '--lib --tests' }} run: | # Don't run the s3 integration tests since docker isn't available diff --git a/Cargo.lock b/Cargo.lock index 906577f07..bed68cb73 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3836,8 +3836,8 @@ checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" [[package]] name = "fsst" -version = "15.0.0-beta.23" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.23#f7ef212132c52f9704c387f342a7ff49a9ebf908" +version = "15.0.0-beta.25" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.25#f5dbd55dd79f1f0412f897ed1917128300fb8c1a" dependencies = [ "arrow-array", "rand 0.9.5", @@ -5315,8 +5315,8 @@ checksum = "e037a2e1d8d5fdbd49b16a4ea09d5d6401c1f29eca5ff29d03d3824dba16256a" [[package]] name = "lance" -version = "15.0.0-beta.23" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.23#f7ef212132c52f9704c387f342a7ff49a9ebf908" +version = "15.0.0-beta.25" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.25#f5dbd55dd79f1f0412f897ed1917128300fb8c1a" dependencies = [ "arc-swap", "arrow", @@ -5391,8 +5391,8 @@ dependencies = [ [[package]] name = "lance-arrow" -version = "15.0.0-beta.23" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.23#f7ef212132c52f9704c387f342a7ff49a9ebf908" +version = "15.0.0-beta.25" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.25#f5dbd55dd79f1f0412f897ed1917128300fb8c1a" dependencies = [ "arrow-array", "arrow-buffer", @@ -5414,7 +5414,7 @@ dependencies = [ [[package]] name = "lance-arrow-scalar" version = "59.0.0" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.23#f7ef212132c52f9704c387f342a7ff49a9ebf908" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.25#f5dbd55dd79f1f0412f897ed1917128300fb8c1a" dependencies = [ "arrow-array", "arrow-buffer", @@ -5428,7 +5428,7 @@ dependencies = [ [[package]] name = "lance-arrow-stats" version = "59.0.0" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.23#f7ef212132c52f9704c387f342a7ff49a9ebf908" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.25#f5dbd55dd79f1f0412f897ed1917128300fb8c1a" dependencies = [ "arrow-array", "arrow-schema", @@ -5437,8 +5437,8 @@ dependencies = [ [[package]] name = "lance-bitpacking" -version = "15.0.0-beta.23" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.23#f7ef212132c52f9704c387f342a7ff49a9ebf908" +version = "15.0.0-beta.25" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.25#f5dbd55dd79f1f0412f897ed1917128300fb8c1a" dependencies = [ "arrayref", "crunchy", @@ -5448,8 +5448,8 @@ dependencies = [ [[package]] name = "lance-core" -version = "15.0.0-beta.23" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.23#f7ef212132c52f9704c387f342a7ff49a9ebf908" +version = "15.0.0-beta.25" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.25#f5dbd55dd79f1f0412f897ed1917128300fb8c1a" dependencies = [ "arrow-array", "arrow-buffer", @@ -5487,8 +5487,8 @@ dependencies = [ [[package]] name = "lance-datafusion" -version = "15.0.0-beta.23" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.23#f7ef212132c52f9704c387f342a7ff49a9ebf908" +version = "15.0.0-beta.25" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.25#f5dbd55dd79f1f0412f897ed1917128300fb8c1a" dependencies = [ "arrow", "arrow-array", @@ -5519,8 +5519,8 @@ dependencies = [ [[package]] name = "lance-datafusion-exec" -version = "15.0.0-beta.23" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.23#f7ef212132c52f9704c387f342a7ff49a9ebf908" +version = "15.0.0-beta.25" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.25#f5dbd55dd79f1f0412f897ed1917128300fb8c1a" dependencies = [ "arrow", "arrow-array", @@ -5545,8 +5545,8 @@ dependencies = [ [[package]] name = "lance-datagen" -version = "15.0.0-beta.23" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.23#f7ef212132c52f9704c387f342a7ff49a9ebf908" +version = "15.0.0-beta.25" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.25#f5dbd55dd79f1f0412f897ed1917128300fb8c1a" dependencies = [ "arrow", "arrow-array", @@ -5563,8 +5563,8 @@ dependencies = [ [[package]] name = "lance-derive" -version = "15.0.0-beta.23" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.23#f7ef212132c52f9704c387f342a7ff49a9ebf908" +version = "15.0.0-beta.25" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.25#f5dbd55dd79f1f0412f897ed1917128300fb8c1a" dependencies = [ "proc-macro2", "quote", @@ -5573,8 +5573,8 @@ dependencies = [ [[package]] name = "lance-encoding" -version = "15.0.0-beta.23" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.23#f7ef212132c52f9704c387f342a7ff49a9ebf908" +version = "15.0.0-beta.25" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.25#f5dbd55dd79f1f0412f897ed1917128300fb8c1a" dependencies = [ "arrow-arith", "arrow-array", @@ -5608,8 +5608,8 @@ dependencies = [ [[package]] name = "lance-file" -version = "15.0.0-beta.23" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.23#f7ef212132c52f9704c387f342a7ff49a9ebf908" +version = "15.0.0-beta.25" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.25#f5dbd55dd79f1f0412f897ed1917128300fb8c1a" dependencies = [ "arrow-arith", "arrow-array", @@ -5640,8 +5640,8 @@ dependencies = [ [[package]] name = "lance-geo" -version = "15.0.0-beta.23" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.23#f7ef212132c52f9704c387f342a7ff49a9ebf908" +version = "15.0.0-beta.25" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.25#f5dbd55dd79f1f0412f897ed1917128300fb8c1a" dependencies = [ "arrow-array", "arrow-schema", @@ -5672,8 +5672,8 @@ dependencies = [ [[package]] name = "lance-index" -version = "15.0.0-beta.23" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.23#f7ef212132c52f9704c387f342a7ff49a9ebf908" +version = "15.0.0-beta.25" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.25#f5dbd55dd79f1f0412f897ed1917128300fb8c1a" dependencies = [ "arc-swap", "arrow", @@ -5746,8 +5746,8 @@ dependencies = [ [[package]] name = "lance-index-core" -version = "15.0.0-beta.23" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.23#f7ef212132c52f9704c387f342a7ff49a9ebf908" +version = "15.0.0-beta.25" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.25#f5dbd55dd79f1f0412f897ed1917128300fb8c1a" dependencies = [ "arrow-array", "arrow-schema", @@ -5770,8 +5770,8 @@ dependencies = [ [[package]] name = "lance-io" -version = "15.0.0-beta.23" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.23#f7ef212132c52f9704c387f342a7ff49a9ebf908" +version = "15.0.0-beta.25" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.25#f5dbd55dd79f1f0412f897ed1917128300fb8c1a" dependencies = [ "arrow", "arrow-array", @@ -5816,8 +5816,8 @@ dependencies = [ [[package]] name = "lance-jsonb" -version = "15.0.0-beta.23" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.23#f7ef212132c52f9704c387f342a7ff49a9ebf908" +version = "15.0.0-beta.25" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.25#f5dbd55dd79f1f0412f897ed1917128300fb8c1a" dependencies = [ "byteorder", "ethnum", @@ -5834,8 +5834,8 @@ dependencies = [ [[package]] name = "lance-linalg" -version = "15.0.0-beta.23" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.23#f7ef212132c52f9704c387f342a7ff49a9ebf908" +version = "15.0.0-beta.25" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.25#f5dbd55dd79f1f0412f897ed1917128300fb8c1a" dependencies = [ "argminmax 0.7.1", "arrow-array", @@ -5850,8 +5850,8 @@ dependencies = [ [[package]] name = "lance-namespace" -version = "15.0.0-beta.23" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.23#f7ef212132c52f9704c387f342a7ff49a9ebf908" +version = "15.0.0-beta.25" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.25#f5dbd55dd79f1f0412f897ed1917128300fb8c1a" dependencies = [ "arrow", "async-trait", @@ -5865,8 +5865,8 @@ dependencies = [ [[package]] name = "lance-namespace-impls" -version = "15.0.0-beta.23" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.23#f7ef212132c52f9704c387f342a7ff49a9ebf908" +version = "15.0.0-beta.25" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.25#f5dbd55dd79f1f0412f897ed1917128300fb8c1a" dependencies = [ "arc-swap", "arrow", @@ -5920,8 +5920,8 @@ dependencies = [ [[package]] name = "lance-select" -version = "15.0.0-beta.23" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.23#f7ef212132c52f9704c387f342a7ff49a9ebf908" +version = "15.0.0-beta.25" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.25#f5dbd55dd79f1f0412f897ed1917128300fb8c1a" dependencies = [ "arrow-array", "arrow-buffer", @@ -5935,8 +5935,8 @@ dependencies = [ [[package]] name = "lance-table" -version = "15.0.0-beta.23" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.23#f7ef212132c52f9704c387f342a7ff49a9ebf908" +version = "15.0.0-beta.25" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.25#f5dbd55dd79f1f0412f897ed1917128300fb8c1a" dependencies = [ "arrow", "arrow-array", @@ -5977,8 +5977,8 @@ dependencies = [ [[package]] name = "lance-testing" -version = "15.0.0-beta.23" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.23#f7ef212132c52f9704c387f342a7ff49a9ebf908" +version = "15.0.0-beta.25" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.25#f5dbd55dd79f1f0412f897ed1917128300fb8c1a" dependencies = [ "arrow-array", "arrow-schema", @@ -5991,8 +5991,8 @@ dependencies = [ [[package]] name = "lance-tokenizer" -version = "15.0.0-beta.23" -source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.23#f7ef212132c52f9704c387f342a7ff49a9ebf908" +version = "15.0.0-beta.25" +source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.25#f5dbd55dd79f1f0412f897ed1917128300fb8c1a" dependencies = [ "frostem", "icu_segmenter", diff --git a/Cargo.toml b/Cargo.toml index 6a8450cf7..1b277c625 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,21 +19,21 @@ categories = ["database-implementations"] rust-version = "1.95.0" [workspace.dependencies] -lance = { "version" = "=15.0.0-beta.23", default-features = false, "tag" = "v15.0.0-beta.23", "git" = "https://github.com/lance-format/lance.git" } -lance-core = { "version" = "=15.0.0-beta.23", "tag" = "v15.0.0-beta.23", "git" = "https://github.com/lance-format/lance.git" } -lance-datagen = { "version" = "=15.0.0-beta.23", "tag" = "v15.0.0-beta.23", "git" = "https://github.com/lance-format/lance.git" } -lance-file = { "version" = "=15.0.0-beta.23", "tag" = "v15.0.0-beta.23", "git" = "https://github.com/lance-format/lance.git" } -lance-io = { "version" = "=15.0.0-beta.23", default-features = false, "tag" = "v15.0.0-beta.23", "git" = "https://github.com/lance-format/lance.git" } -lance-index = { "version" = "=15.0.0-beta.23", "tag" = "v15.0.0-beta.23", "git" = "https://github.com/lance-format/lance.git" } -lance-jsonb = { "version" = "=15.0.0-beta.23", "tag" = "v15.0.0-beta.23", "git" = "https://github.com/lance-format/lance.git" } -lance-linalg = { "version" = "=15.0.0-beta.23", "tag" = "v15.0.0-beta.23", "git" = "https://github.com/lance-format/lance.git" } -lance-namespace = { "version" = "=15.0.0-beta.23", "tag" = "v15.0.0-beta.23", "git" = "https://github.com/lance-format/lance.git" } -lance-namespace-impls = { "version" = "=15.0.0-beta.23", default-features = false, "tag" = "v15.0.0-beta.23", "git" = "https://github.com/lance-format/lance.git" } -lance-table = { "version" = "=15.0.0-beta.23", "tag" = "v15.0.0-beta.23", "git" = "https://github.com/lance-format/lance.git" } -lance-testing = { "version" = "=15.0.0-beta.23", "tag" = "v15.0.0-beta.23", "git" = "https://github.com/lance-format/lance.git" } -lance-datafusion = { "version" = "=15.0.0-beta.23", "tag" = "v15.0.0-beta.23", "git" = "https://github.com/lance-format/lance.git" } -lance-encoding = { "version" = "=15.0.0-beta.23", "tag" = "v15.0.0-beta.23", "git" = "https://github.com/lance-format/lance.git" } -lance-arrow = { "version" = "=15.0.0-beta.23", "tag" = "v15.0.0-beta.23", "git" = "https://github.com/lance-format/lance.git" } +lance = { "version" = "=15.0.0-beta.25", default-features = false, "tag" = "v15.0.0-beta.25", "git" = "https://github.com/lance-format/lance.git" } +lance-core = { "version" = "=15.0.0-beta.25", "tag" = "v15.0.0-beta.25", "git" = "https://github.com/lance-format/lance.git" } +lance-datagen = { "version" = "=15.0.0-beta.25", "tag" = "v15.0.0-beta.25", "git" = "https://github.com/lance-format/lance.git" } +lance-file = { "version" = "=15.0.0-beta.25", "tag" = "v15.0.0-beta.25", "git" = "https://github.com/lance-format/lance.git" } +lance-io = { "version" = "=15.0.0-beta.25", default-features = false, "tag" = "v15.0.0-beta.25", "git" = "https://github.com/lance-format/lance.git" } +lance-index = { "version" = "=15.0.0-beta.25", "tag" = "v15.0.0-beta.25", "git" = "https://github.com/lance-format/lance.git" } +lance-jsonb = { "version" = "=15.0.0-beta.25", "tag" = "v15.0.0-beta.25", "git" = "https://github.com/lance-format/lance.git" } +lance-linalg = { "version" = "=15.0.0-beta.25", "tag" = "v15.0.0-beta.25", "git" = "https://github.com/lance-format/lance.git" } +lance-namespace = { "version" = "=15.0.0-beta.25", "tag" = "v15.0.0-beta.25", "git" = "https://github.com/lance-format/lance.git" } +lance-namespace-impls = { "version" = "=15.0.0-beta.25", default-features = false, "tag" = "v15.0.0-beta.25", "git" = "https://github.com/lance-format/lance.git" } +lance-table = { "version" = "=15.0.0-beta.25", "tag" = "v15.0.0-beta.25", "git" = "https://github.com/lance-format/lance.git" } +lance-testing = { "version" = "=15.0.0-beta.25", "tag" = "v15.0.0-beta.25", "git" = "https://github.com/lance-format/lance.git" } +lance-datafusion = { "version" = "=15.0.0-beta.25", "tag" = "v15.0.0-beta.25", "git" = "https://github.com/lance-format/lance.git" } +lance-encoding = { "version" = "=15.0.0-beta.25", "tag" = "v15.0.0-beta.25", "git" = "https://github.com/lance-format/lance.git" } +lance-arrow = { "version" = "=15.0.0-beta.25", "tag" = "v15.0.0-beta.25", "git" = "https://github.com/lance-format/lance.git" } lancedb = { path = "rust/lancedb", default-features = false } ahash = "0.8" anyhow = "1" diff --git a/java/pom.xml b/java/pom.xml index 43b70e500..4ccbc59e4 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -28,7 +28,7 @@ UTF-8 15.0.0 - 15.0.0-beta.23 + 15.0.0-beta.25 2.18.12 false 2.30.0 diff --git a/python/pyproject.toml b/python/pyproject.toml index 201e9fd07..ff64d9772 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -64,7 +64,7 @@ tests = [ "polars>=0.19, <=1.32.3", "pyarrow>=16", "pyarrow-stubs>=16.0", - "pylance==15.0.0b23", + "pylance==15.0.0b25", "requests>=2.31.0", "datafusion>=54,<55", "opentelemetry-sdk>=1.30.0", diff --git a/python/uv.lock b/python/uv.lock index 0cbcea617..6b1a96c2e 100644 --- a/python/uv.lock +++ b/python/uv.lock @@ -2147,7 +2147,7 @@ requires-dist = [ { name = "pyarrow-stubs", marker = "extra == 'tests'", specifier = ">=16.0" }, { name = "pydantic", specifier = ">=2.7.4,<3" }, { name = "pylance", marker = "extra == 'pylance'", specifier = ">=15.0.0b3" }, - { name = "pylance", marker = "extra == 'tests'", specifier = "==15.0.0b23" }, + { name = "pylance", marker = "extra == 'tests'", specifier = "==15.0.0b25" }, { name = "pyright", marker = "extra == 'dev'", specifier = ">=1.1.350" }, { name = "pytest", marker = "extra == 'tests'", specifier = ">=7.0" }, { name = "pytest-asyncio", marker = "extra == 'tests'", specifier = ">=0.21" }, @@ -4301,7 +4301,7 @@ crypto = [ [[package]] name = "pylance" -version = "15.0.0b23" +version = "15.0.0b25" source = { registry = "https://pypi.fury.io/lance-format/" } dependencies = [ { name = "lance-namespace" }, @@ -4312,13 +4312,13 @@ dependencies = [ { name = "pyarrow", version = "26.0.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" }, ] wheels = [ - { url = "https://pypi.fury.io/lance-format/-/ver_ldwuz/pylance-15.0.0b23-cp310-abi3-macosx_11_0_arm64.whl", hash = "sha256:b7980c606424e63e9be645536dbcaff75b479886a53abdae3aef64684c9a6fc4" }, - { url = "https://pypi.fury.io/lance-format/-/ver_5wKzE/pylance-15.0.0b23-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a6d887bc81d5f79b8a23d5cbc840cb56dbea4d8b0a9d2c2edf063dea48bcf741" }, - { url = "https://pypi.fury.io/lance-format/-/ver_FKuk6/pylance-15.0.0b23-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1424bd48cac2160b7745c9b87cd24d81c7cf2b0a89f342ea46ecd2a473ea74e6" }, - { url = "https://pypi.fury.io/lance-format/-/ver_SVglj/pylance-15.0.0b23-cp310-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:09de71b60ac6b8b91fdd73207f71c74bc521626de7e437102ebfe4f2c1f78fa0" }, - { url = "https://pypi.fury.io/lance-format/-/ver_SgTr6/pylance-15.0.0b23-cp310-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:d9385471578bec51ae546f7bd7ea638e20bd12d687082d43ed465017dfd992e7" }, - { url = "https://pypi.fury.io/lance-format/-/ver_wyipY/pylance-15.0.0b23-cp310-abi3-win_amd64.whl", hash = "sha256:7b98b0d78564c5acea3693334c41dc3ced20484fb2c8e738113eeb078281a109" }, - { url = "https://pypi.fury.io/lance-format/-/ver_1v2uEn/pylance-15.0.0b23-cp310-abi3-win_arm64.whl", hash = "sha256:0f4d2645143d44c11237e6ea00772c169a3c6ed23a7c36beaeaef9a18d1be14d" }, + { url = "https://pypi.fury.io/lance-format/-/ver_2hpc2R/pylance-15.0.0b25-cp310-abi3-macosx_11_0_arm64.whl", hash = "sha256:2a0bb8d6b0c55b7a821989759fc0f8f62cb4da621f89eae232cef49bb7ef341e" }, + { url = "https://pypi.fury.io/lance-format/-/ver_4LUKQ/pylance-15.0.0b25-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9b73e6e9373c4d5af3fea51e63c3e55873f470aa1a6d0412c22916f88ff5df88" }, + { url = "https://pypi.fury.io/lance-format/-/ver_11CcHk/pylance-15.0.0b25-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8090d403b2a38cd4ac8eb09de0327bc404cb3bc965d905f2b6a8479891273fae" }, + { url = "https://pypi.fury.io/lance-format/-/ver_1S87Ih/pylance-15.0.0b25-cp310-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:7f0a20e8ed41d3e49cd5e0bbba97d18ad684cf337e053641321404c9db34f1a1" }, + { url = "https://pypi.fury.io/lance-format/-/ver_13KmLJ/pylance-15.0.0b25-cp310-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:079385a6816a10d42f57bc467d9c822c7207cd31d9a6f768bbf522c0a3007229" }, + { url = "https://pypi.fury.io/lance-format/-/ver_1bTDlQ/pylance-15.0.0b25-cp310-abi3-win_amd64.whl", hash = "sha256:d9b1d713b0d03043a3f5596e909405787f85219f54c427b14437367f0ea7acb9" }, + { url = "https://pypi.fury.io/lance-format/-/ver_j7adN/pylance-15.0.0b25-cp310-abi3-win_arm64.whl", hash = "sha256:4a1c18176ffd6a860c6e66b0deb39fcc9ac1434dba57ee66559b7638ad4a200a" }, ] [[package]] diff --git a/rust/lancedb/src/table/refresh.rs b/rust/lancedb/src/table/refresh.rs index 879527f24..f6bab98f5 100644 --- a/rust/lancedb/src/table/refresh.rs +++ b/rust/lancedb/src/table/refresh.rs @@ -653,7 +653,10 @@ async fn execute_refresh_column_with_source( let session = dataset.session(); let new_dataset = Dataset::commit( WriteDestination::Dataset(dataset.clone()), - Operation::DataReplacement { replacements }, + Operation::DataReplacement { + replacements, + data_change: true, + }, Some(source_version), None, None, From 57b20fb11d907fd8948827370e7c4032d396c205 Mon Sep 17 00:00:00 2001 From: Lance Release Date: Tue, 17 Nov 2026 08:56:28 +0000 Subject: [PATCH 5/5] =?UTF-8?q?Bump=20version:=200.42.0-beta.17=20?= =?UTF-8?q?=E2=86=92=200.42.0-beta.18?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.toml | 2 +- Cargo.lock | 8 ++++---- docs/src/java/java.md | 2 +- java/lancedb-core/pom.xml | 2 +- java/pom.xml | 2 +- nodejs/Cargo.toml | 2 +- nodejs/npm/darwin-arm64/package.json | 2 +- nodejs/npm/linux-arm64-gnu/package.json | 2 +- nodejs/npm/linux-arm64-musl/package.json | 2 +- nodejs/npm/linux-x64-gnu/package.json | 2 +- nodejs/npm/linux-x64-musl/package.json | 2 +- nodejs/npm/win32-arm64-msvc/package.json | 2 +- nodejs/npm/win32-x64-msvc/package.json | 2 +- nodejs/package.json | 2 +- python/Cargo.toml | 2 +- rust/lancedb/Cargo.toml | 2 +- rust/lancedb/cli/Cargo.toml | 2 +- 17 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.bumpversion.toml b/.bumpversion.toml index 9ddd23172..8f10d67f0 100644 --- a/.bumpversion.toml +++ b/.bumpversion.toml @@ -1,5 +1,5 @@ [tool.bumpversion] -current_version = "0.42.0-beta.17" +current_version = "0.42.0-beta.18" parse = """(?x) (?P0|[1-9]\\d*)\\. (?P0|[1-9]\\d*)\\. diff --git a/Cargo.lock b/Cargo.lock index bed68cb73..6a23569a8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6005,7 +6005,7 @@ dependencies = [ [[package]] name = "lancedb" -version = "0.42.0-beta.17" +version = "0.42.0-beta.18" dependencies = [ "ahash", "anyhow", @@ -6116,7 +6116,7 @@ dependencies = [ [[package]] name = "lancedb-cli" -version = "0.42.0-beta.17" +version = "0.42.0-beta.18" dependencies = [ "anyhow", "arrow-array", @@ -6159,7 +6159,7 @@ dependencies = [ [[package]] name = "lancedb-nodejs" -version = "0.42.0-beta.17" +version = "0.42.0-beta.18" dependencies = [ "arrow-array", "arrow-buffer", @@ -6184,7 +6184,7 @@ dependencies = [ [[package]] name = "lancedb-python" -version = "0.42.0-beta.17" +version = "0.42.0-beta.18" dependencies = [ "arc-swap", "arrow", diff --git a/docs/src/java/java.md b/docs/src/java/java.md index 4aa029baf..1a8347ad5 100644 --- a/docs/src/java/java.md +++ b/docs/src/java/java.md @@ -14,7 +14,7 @@ Add the following dependency to your `pom.xml`: com.lancedb lancedb-core - 0.42.0-beta.17 + 0.42.0-beta.18 ``` diff --git a/java/lancedb-core/pom.xml b/java/lancedb-core/pom.xml index 2301b9e1d..c15bc0774 100644 --- a/java/lancedb-core/pom.xml +++ b/java/lancedb-core/pom.xml @@ -8,7 +8,7 @@ com.lancedb lancedb-parent - 0.42.0-beta.17 + 0.42.0-beta.18 ../pom.xml diff --git a/java/pom.xml b/java/pom.xml index 4ccbc59e4..dce3deba3 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -6,7 +6,7 @@ com.lancedb lancedb-parent - 0.42.0-beta.17 + 0.42.0-beta.18 pom ${project.artifactId} LanceDB Java SDK Parent POM diff --git a/nodejs/Cargo.toml b/nodejs/Cargo.toml index c0bf9ca9b..e523c1138 100644 --- a/nodejs/Cargo.toml +++ b/nodejs/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "lancedb-nodejs" edition.workspace = true -version = "0.42.0-beta.17" +version = "0.42.0-beta.18" publish = false license.workspace = true description.workspace = true diff --git a/nodejs/npm/darwin-arm64/package.json b/nodejs/npm/darwin-arm64/package.json index 924ff3967..d603a2c8f 100644 --- a/nodejs/npm/darwin-arm64/package.json +++ b/nodejs/npm/darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "@lancedb/lancedb-darwin-arm64", - "version": "0.42.0-beta.17", + "version": "0.42.0-beta.18", "os": ["darwin"], "cpu": ["arm64"], "main": "lancedb.darwin-arm64.node", diff --git a/nodejs/npm/linux-arm64-gnu/package.json b/nodejs/npm/linux-arm64-gnu/package.json index b265cd7f1..8115e27f9 100644 --- a/nodejs/npm/linux-arm64-gnu/package.json +++ b/nodejs/npm/linux-arm64-gnu/package.json @@ -1,6 +1,6 @@ { "name": "@lancedb/lancedb-linux-arm64-gnu", - "version": "0.42.0-beta.17", + "version": "0.42.0-beta.18", "os": ["linux"], "cpu": ["arm64"], "main": "lancedb.linux-arm64-gnu.node", diff --git a/nodejs/npm/linux-arm64-musl/package.json b/nodejs/npm/linux-arm64-musl/package.json index 031d20477..f3cdd7253 100644 --- a/nodejs/npm/linux-arm64-musl/package.json +++ b/nodejs/npm/linux-arm64-musl/package.json @@ -1,6 +1,6 @@ { "name": "@lancedb/lancedb-linux-arm64-musl", - "version": "0.42.0-beta.17", + "version": "0.42.0-beta.18", "os": ["linux"], "cpu": ["arm64"], "main": "lancedb.linux-arm64-musl.node", diff --git a/nodejs/npm/linux-x64-gnu/package.json b/nodejs/npm/linux-x64-gnu/package.json index 6c71adeee..4d165c4de 100644 --- a/nodejs/npm/linux-x64-gnu/package.json +++ b/nodejs/npm/linux-x64-gnu/package.json @@ -1,6 +1,6 @@ { "name": "@lancedb/lancedb-linux-x64-gnu", - "version": "0.42.0-beta.17", + "version": "0.42.0-beta.18", "os": ["linux"], "cpu": ["x64"], "main": "lancedb.linux-x64-gnu.node", diff --git a/nodejs/npm/linux-x64-musl/package.json b/nodejs/npm/linux-x64-musl/package.json index 2d05ddca1..d884605b6 100644 --- a/nodejs/npm/linux-x64-musl/package.json +++ b/nodejs/npm/linux-x64-musl/package.json @@ -1,6 +1,6 @@ { "name": "@lancedb/lancedb-linux-x64-musl", - "version": "0.42.0-beta.17", + "version": "0.42.0-beta.18", "os": ["linux"], "cpu": ["x64"], "main": "lancedb.linux-x64-musl.node", diff --git a/nodejs/npm/win32-arm64-msvc/package.json b/nodejs/npm/win32-arm64-msvc/package.json index 013568ae2..2b6bdc8da 100644 --- a/nodejs/npm/win32-arm64-msvc/package.json +++ b/nodejs/npm/win32-arm64-msvc/package.json @@ -1,6 +1,6 @@ { "name": "@lancedb/lancedb-win32-arm64-msvc", - "version": "0.42.0-beta.17", + "version": "0.42.0-beta.18", "os": [ "win32" ], diff --git a/nodejs/npm/win32-x64-msvc/package.json b/nodejs/npm/win32-x64-msvc/package.json index fec9adb4f..1402f5bee 100644 --- a/nodejs/npm/win32-x64-msvc/package.json +++ b/nodejs/npm/win32-x64-msvc/package.json @@ -1,6 +1,6 @@ { "name": "@lancedb/lancedb-win32-x64-msvc", - "version": "0.42.0-beta.17", + "version": "0.42.0-beta.18", "os": ["win32"], "cpu": ["x64"], "main": "lancedb.win32-x64-msvc.node", diff --git a/nodejs/package.json b/nodejs/package.json index cd8dd8be7..a0cf05acb 100644 --- a/nodejs/package.json +++ b/nodejs/package.json @@ -11,7 +11,7 @@ "ann" ], "private": false, - "version": "0.42.0-beta.17", + "version": "0.42.0-beta.18", "main": "dist/index.js", "exports": { ".": "./dist/index.js", diff --git a/python/Cargo.toml b/python/Cargo.toml index 189950963..9ba87dcd5 100644 --- a/python/Cargo.toml +++ b/python/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lancedb-python" -version = "0.42.0-beta.17" +version = "0.42.0-beta.18" publish = false edition.workspace = true description = "Python bindings for LanceDB" diff --git a/rust/lancedb/Cargo.toml b/rust/lancedb/Cargo.toml index 34e91dbfd..28e8c501b 100644 --- a/rust/lancedb/Cargo.toml +++ b/rust/lancedb/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lancedb" -version = "0.42.0-beta.17" +version = "0.42.0-beta.18" edition.workspace = true description = "LanceDB: A serverless, low-latency vector database for AI applications" license.workspace = true diff --git a/rust/lancedb/cli/Cargo.toml b/rust/lancedb/cli/Cargo.toml index ff16ccb7b..689200452 100644 --- a/rust/lancedb/cli/Cargo.toml +++ b/rust/lancedb/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lancedb-cli" -version = "0.42.0-beta.17" +version = "0.42.0-beta.18" edition = "2021" license.workspace = true repository.workspace = true