mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-13 14:16:54 +00:00
feat(python)!: rename the @udf decorator to @function (#4837)
The client registers Functions, but the decorator that packages one was called `udf` and produced a `UdfDefinition`. Rename them to `function` and `FunctionDefinition`, and say "function" instead of "UDF" in the docstrings, error messages and docs around them. `udf` and `UdfDefinition` stay as deprecated aliases that emit a `DeprecationWarning`. The source packager strips either spelling of the decorator, so `@udf` and `@function` produce the same artifact and digest, and the wire contract is unchanged. DataFusion and Lance UDF types, and Geneva's `@udf` in the integration docs, are unrelated and untouched.
This commit is contained in:
@@ -382,7 +382,7 @@ code that used the former LanceDB Enterprise-only argument order.
|
||||
|
||||
## Functions and Jobs
|
||||
|
||||
A decorated `udf` definition is also a local callable. Call a decorated function
|
||||
A `@function` definition is also a local callable. Call a decorated function
|
||||
directly with row inputs, or call a decorated class with its initialization fields
|
||||
and then call the returned instance; call `close()` if the class defines it. This
|
||||
path uses the current Python environment and does not create a registered
|
||||
@@ -391,15 +391,15 @@ the remote Arrow adapter. A registered `FunctionVersion` call instead binds
|
||||
`col(...)` inputs and returns a remote `FunctionApplication`.
|
||||
|
||||
```python
|
||||
from lancedb import udf
|
||||
from lancedb import function
|
||||
|
||||
|
||||
@udf
|
||||
@function
|
||||
def normalize(text: str) -> str:
|
||||
return text.strip().lower()
|
||||
|
||||
|
||||
@udf
|
||||
@function
|
||||
class Scale:
|
||||
def __init__(self, factor: float):
|
||||
self.factor = factor
|
||||
@@ -455,9 +455,9 @@ with BlobReader(read_range, len(payload)) as reader:
|
||||
|
||||
::: lancedb.functions.PythonEnvironmentSpec
|
||||
|
||||
::: lancedb.functions.udf
|
||||
::: lancedb.functions.function
|
||||
|
||||
::: lancedb.functions.UdfDefinition
|
||||
::: lancedb.functions.FunctionDefinition
|
||||
|
||||
::: lancedb.secrets.EnvVarSecret
|
||||
|
||||
|
||||
Reference in New Issue
Block a user