w.functions: Functions¶
- class databricks.sdk.service.catalog.FunctionsAPI¶
Functions implement User-Defined Functions (UDFs) in Unity Catalog.
The function implementation can be any SQL expression or Query, and it can be invoked wherever a table reference is allowed in a query. In Unity Catalog, a function resides at the same level as a table, so it can be referenced with the form catalog_name.**schema_name**.**function_name**.
- create(function_info: CreateFunction) FunctionInfo¶
WARNING: This API is experimental and will change in future versions
Creates a new function
The user must have the following permissions in order for the function to be created:
USE_CATALOG on the function’s parent catalog
USE_SCHEMA and CREATE_FUNCTION on the function’s parent schema
- Parameters:
function_info –
CreateFunctionPartial FunctionInfo specifying the function to be created.- Returns:
- delete(name: str [, force: Optional[bool]])¶
Deletes the function that matches the supplied name. For the deletion to succeed, the user must satisfy one of the following conditions:
Is the owner of the function’s parent catalog
Is the owner of the function’s parent schema and have the USE_CATALOG privilege on its parent catalog
Is the owner of the function itself and have both the USE_CATALOG privilege on its parent catalog and the USE_SCHEMA privilege on its parent schema
- Parameters:
name – str The fully-qualified name of the function (of the form catalog_name.**schema_name**.**function__name**) .
force – bool (optional) Force deletion even if the function is notempty.
- get(name: str [, include_browse: Optional[bool]]) FunctionInfo¶
Gets a function from within a parent catalog and schema. For the fetch to succeed, the user must satisfy one of the following requirements:
Is a metastore admin
Is an owner of the function’s parent catalog
Have the USE_CATALOG privilege on the function’s parent catalog and be the owner of the function
Have the USE_CATALOG privilege on the function’s parent catalog, the USE_SCHEMA privilege on the function’s parent schema, and the EXECUTE privilege on the function itself
- Parameters:
name – str The fully-qualified name of the function (of the form catalog_name.**schema_name**.**function__name**).
include_browse – bool (optional) Whether to include functions in the response for which the principal can only access selective metadata for
- Returns:
- list(catalog_name: str, schema_name: str [, include_browse: Optional[bool], max_results: Optional[int], page_token: Optional[str]]) Iterator[FunctionInfo]¶
List functions within the specified parent catalog and schema. If the user is a metastore admin, all functions are returned in the output list. Otherwise, the user must have the USE_CATALOG privilege on the catalog and the USE_SCHEMA privilege on the schema, and the output list contains only functions for which either the user has the EXECUTE privilege or the user is the owner. There is no guarantee of a specific ordering of the elements in the array.
NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon.
PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token. Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
- Parameters:
catalog_name – str Name of parent catalog for functions of interest.
schema_name – str Parent schema of functions.
include_browse – bool (optional) Whether to include functions in the response for which the principal can only access selective metadata for
max_results –
int (optional) Maximum number of functions to return. If not set, all the functions are returned (not recommended).
when set to a value greater than 0, the page length is the minimum of this value and a server configured value;
when set to 0, the page length is set to a server configured value (recommended);
when set to a value less than 0, an invalid parameter error is returned;
page_token – str (optional) Opaque pagination token to go to next page based on previous query.
- Returns:
Iterator over
FunctionInfo
- update(name: str [, owner: Optional[str]]) FunctionInfo¶
Updates the function that matches the supplied name. Only the owner of the function can be updated. If the user is not a metastore admin, the user must be a member of the group that is the new function owner.
Is a metastore admin
Is the owner of the function’s parent catalog
Is the owner of the function’s parent schema and has the USE_CATALOG privilege on its parent catalog
Is the owner of the function itself and has the USE_CATALOG privilege on its parent catalog as well as the USE_SCHEMA privilege on the function’s parent schema.
- Parameters:
name – str The fully-qualified name of the function (of the form catalog_name.**schema_name**.**function__name**).
owner – str (optional) Username of current owner of the function.
- Returns: