functions
Creates, updates, deletes, gets or lists a functions resource.
Overview
| Name | functions |
| Type | Resource |
| Id | databricks_workspace.catalog.functions |
Fields
The following fields are returned by SELECT queries:
- get
- list
| Name | Datatype | Description |
|---|---|---|
name | string | Name of function, relative to parent schema. |
function_id | string | Id of Function, relative to parent schema. |
metastore_id | string | Unique identifier of parent metastore. |
catalog_name | string | Name of parent Catalog. |
external_name | string | External function name. |
full_name | string | Full name of Function, in form of **catalog_name**.**schema_name**.**function_name** |
schema_name | string | Name of parent Schema relative to its parent Catalog. |
specific_name | string | Specific name of the function; Reserved for future use. |
browse_only | boolean | |
comment | string | User-provided free-form text description. |
created_at | integer | Time at which this function was created, in epoch milliseconds. |
created_by | string | Username of function creator. |
data_type | string | Scalar function return data type. (ARRAY, BINARY, BOOLEAN, BYTE, CHAR, DATE, DECIMAL, DOUBLE, FLOAT, GEOGRAPHY, GEOMETRY, INT, INTERVAL, LONG, MAP, NULL, SHORT, STRING, STRUCT, TABLE_TYPE, TIMESTAMP, TIMESTAMP_NTZ, USER_DEFINED_TYPE, VARIANT) |
external_language | string | External function language. |
full_data_type | string | Pretty printed function data type. |
input_params | object | Function input parameters. |
is_deterministic | boolean | Whether the function is deterministic. |
is_null_call | boolean | Function null call. |
owner | string | Username of current owner of the function. |
parameter_style | string | Function parameter style. **S** is the value for SQL. (S) |
properties | string | JSON-serialized key-value pair map, encoded (escaped) as a string. |
return_params | object | Table function return parameters. |
routine_body | string | Function language. When **EXTERNAL** is used, the language of the routine function should be specified in the **external_language** field, and the **return_params** of the function cannot be used (as **TABLE** return type is not supported), and the **sql_data_access** field must be **NO_SQL**. (EXTERNAL, SQL) |
routine_definition | string | Function body. |
routine_dependencies | object | function dependencies. |
security_type | string | Function security type. (DEFINER) |
sql_data_access | string | Function SQL data access. (CONTAINS_SQL, NO_SQL, READS_SQL_DATA) |
sql_path | string | List of schemes whose objects can be referenced without qualification. |
updated_at | integer | Time at which this function was last modified, in epoch milliseconds. |
updated_by | string | Username of user who last modified the function. |
| Name | Datatype | Description |
|---|---|---|
name | string | Name of function, relative to parent schema. |
function_id | string | Id of Function, relative to parent schema. |
metastore_id | string | Unique identifier of parent metastore. |
catalog_name | string | Name of parent Catalog. |
external_name | string | External function name. |
full_name | string | Full name of Function, in form of **catalog_name**.**schema_name**.**function_name** |
schema_name | string | Name of parent Schema relative to its parent Catalog. |
specific_name | string | Specific name of the function; Reserved for future use. |
browse_only | boolean | |
comment | string | User-provided free-form text description. |
created_at | integer | Time at which this function was created, in epoch milliseconds. |
created_by | string | Username of function creator. |
data_type | string | Scalar function return data type. (ARRAY, BINARY, BOOLEAN, BYTE, CHAR, DATE, DECIMAL, DOUBLE, FLOAT, GEOGRAPHY, GEOMETRY, INT, INTERVAL, LONG, MAP, NULL, SHORT, STRING, STRUCT, TABLE_TYPE, TIMESTAMP, TIMESTAMP_NTZ, USER_DEFINED_TYPE, VARIANT) |
external_language | string | External function language. |
full_data_type | string | Pretty printed function data type. |
input_params | object | Function input parameters. |
is_deterministic | boolean | Whether the function is deterministic. |
is_null_call | boolean | Function null call. |
owner | string | Username of current owner of the function. |
parameter_style | string | Function parameter style. **S** is the value for SQL. (S) |
properties | string | JSON-serialized key-value pair map, encoded (escaped) as a string. |
return_params | object | Table function return parameters. |
routine_body | string | Function language. When **EXTERNAL** is used, the language of the routine function should be specified in the **external_language** field, and the **return_params** of the function cannot be used (as **TABLE** return type is not supported), and the **sql_data_access** field must be **NO_SQL**. (EXTERNAL, SQL) |
routine_definition | string | Function body. |
routine_dependencies | object | function dependencies. |
security_type | string | Function security type. (DEFINER) |
sql_data_access | string | Function SQL data access. (CONTAINS_SQL, NO_SQL, READS_SQL_DATA) |
sql_path | string | List of schemes whose objects can be referenced without qualification. |
updated_at | integer | Time at which this function was last modified, in epoch milliseconds. |
updated_by | string | Username of user who last modified the function. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | name, deployment_name | include_browse | Gets a function from within a parent catalog and schema. For the fetch to succeed, the user must |
list | select | catalog_name, schema_name, deployment_name | include_browse, max_results, page_token | List functions within the specified parent catalog and schema. If the user is a metastore admin, all |
create | insert | deployment_name, function_info | WARNING: This API is experimental and will change in future versions | |
update | update | name, deployment_name | Updates the function that matches the supplied name. Only the owner of the function can be updated. If | |
delete | delete | name, deployment_name | force | Deletes the function that matches the supplied name. For the deletion to succeed, the user must |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
catalog_name | string | Name of parent catalog for functions of interest. |
deployment_name | string | The Databricks Workspace Deployment Name (default: dbc-abcd0123-a1bc) |
name | string | The fully-qualified name of the function (of the form catalog_name.schema_name.function__name) . |
schema_name | string | Parent schema of functions. |
force | boolean | Force deletion even if the function is notempty. |
include_browse | boolean | Whether to include functions in the response for which the principal can only access selective metadata for |
max_results | integer | 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 | string | Opaque pagination token to go to next page based on previous query. |
SELECT examples
- get
- list
Gets a function from within a parent catalog and schema. For the fetch to succeed, the user must
SELECT
name,
function_id,
metastore_id,
catalog_name,
external_name,
full_name,
schema_name,
specific_name,
browse_only,
comment,
created_at,
created_by,
data_type,
external_language,
full_data_type,
input_params,
is_deterministic,
is_null_call,
owner,
parameter_style,
properties,
return_params,
routine_body,
routine_definition,
routine_dependencies,
security_type,
sql_data_access,
sql_path,
updated_at,
updated_by
FROM databricks_workspace.catalog.functions
WHERE name = '{{ name }}' -- required
AND deployment_name = '{{ deployment_name }}' -- required
AND include_browse = '{{ include_browse }}'
;
List functions within the specified parent catalog and schema. If the user is a metastore admin, all
SELECT
name,
function_id,
metastore_id,
catalog_name,
external_name,
full_name,
schema_name,
specific_name,
browse_only,
comment,
created_at,
created_by,
data_type,
external_language,
full_data_type,
input_params,
is_deterministic,
is_null_call,
owner,
parameter_style,
properties,
return_params,
routine_body,
routine_definition,
routine_dependencies,
security_type,
sql_data_access,
sql_path,
updated_at,
updated_by
FROM databricks_workspace.catalog.functions
WHERE catalog_name = '{{ catalog_name }}' -- required
AND schema_name = '{{ schema_name }}' -- required
AND deployment_name = '{{ deployment_name }}' -- required
AND include_browse = '{{ include_browse }}'
AND max_results = '{{ max_results }}'
AND page_token = '{{ page_token }}'
;
INSERT examples
- create
- Manifest
WARNING: This API is experimental and will change in future versions
INSERT INTO databricks_workspace.catalog.functions (
function_info,
deployment_name
)
SELECT
'{{ function_info }}' /* required */,
'{{ deployment_name }}'
RETURNING
name,
function_id,
metastore_id,
catalog_name,
external_name,
full_name,
schema_name,
specific_name,
browse_only,
comment,
created_at,
created_by,
data_type,
external_language,
full_data_type,
input_params,
is_deterministic,
is_null_call,
owner,
parameter_style,
properties,
return_params,
routine_body,
routine_definition,
routine_dependencies,
security_type,
sql_data_access,
sql_path,
updated_at,
updated_by
;
# Description fields are for documentation purposes
- name: functions
props:
- name: deployment_name
value: "{{ deployment_name }}"
description: Required parameter for the functions resource.
- name: function_info
description: |
Partial __FunctionInfo__ specifying the function to be created.
value:
name: "{{ name }}"
catalog_name: "{{ catalog_name }}"
schema_name: "{{ schema_name }}"
input_params:
parameters:
- name: "{{ name }}"
type_text: "{{ type_text }}"
type_name: "{{ type_name }}"
position: {{ position }}
comment: "{{ comment }}"
parameter_default: "{{ parameter_default }}"
parameter_mode: "{{ parameter_mode }}"
parameter_type: "{{ parameter_type }}"
type_interval_type: "{{ type_interval_type }}"
type_json: "{{ type_json }}"
type_precision: {{ type_precision }}
type_scale: {{ type_scale }}
data_type: "{{ data_type }}"
full_data_type: "{{ full_data_type }}"
routine_body: "{{ routine_body }}"
routine_definition: "{{ routine_definition }}"
parameter_style: "{{ parameter_style }}"
is_deterministic: {{ is_deterministic }}
sql_data_access: "{{ sql_data_access }}"
is_null_call: {{ is_null_call }}
security_type: "{{ security_type }}"
specific_name: "{{ specific_name }}"
comment: "{{ comment }}"
external_language: "{{ external_language }}"
external_name: "{{ external_name }}"
properties: "{{ properties }}"
return_params:
parameters:
- name: "{{ name }}"
type_text: "{{ type_text }}"
type_name: "{{ type_name }}"
position: {{ position }}
comment: "{{ comment }}"
parameter_default: "{{ parameter_default }}"
parameter_mode: "{{ parameter_mode }}"
parameter_type: "{{ parameter_type }}"
type_interval_type: "{{ type_interval_type }}"
type_json: "{{ type_json }}"
type_precision: {{ type_precision }}
type_scale: {{ type_scale }}
routine_dependencies:
dependencies:
- connection:
connection_name: "{{ connection_name }}"
credential:
credential_name: "{{ credential_name }}"
function:
function_full_name: "{{ function_full_name }}"
table:
table_full_name: "{{ table_full_name }}"
sql_path: "{{ sql_path }}"
UPDATE examples
- update
Updates the function that matches the supplied name. Only the owner of the function can be updated. If
UPDATE databricks_workspace.catalog.functions
SET
owner = '{{ owner }}'
WHERE
name = '{{ name }}' --required
AND deployment_name = '{{ deployment_name }}' --required
RETURNING
name,
function_id,
metastore_id,
catalog_name,
external_name,
full_name,
schema_name,
specific_name,
browse_only,
comment,
created_at,
created_by,
data_type,
external_language,
full_data_type,
input_params,
is_deterministic,
is_null_call,
owner,
parameter_style,
properties,
return_params,
routine_body,
routine_definition,
routine_dependencies,
security_type,
sql_data_access,
sql_path,
updated_at,
updated_by;
DELETE examples
- delete
Deletes the function that matches the supplied name. For the deletion to succeed, the user must
DELETE FROM databricks_workspace.catalog.functions
WHERE name = '{{ name }}' --required
AND deployment_name = '{{ deployment_name }}' --required
AND force = '{{ force }}'
;