Skip to main content

functions

Creates, updates, deletes, gets or lists a functions resource.

Overview

Namefunctions
TypeResource
Idclickhouse.udfs.functions

Fields

The following fields are returned by SELECT queries:

Successful response.

NameDatatypeDescription
function_namestringName of the UDF. Unique within the organization. (wire: functionName)
return_namestringName of the returned value, or null when unnamed. (wire: returnName)
argumentsarrayArguments passed to the UDF command.
command_read_timeoutintegerCommand stdout read timeout in milliseconds. (wire: commandReadTimeout)
command_write_timeoutintegerCommand stdin write timeout in milliseconds. (wire: commandWriteTimeout)
created_atstring (date-time)Creation timestamp. (wire: createdAt)
errorstringBuild error, or null when no build error is present.
formatstringInput and output format used by the UDF command.
max_command_execution_timeintegerMaximum command execution time in seconds for executable_pool UDFs. (wire: maxCommandExecutionTime)
memory_limit_mibintegerMaximum memory, in MiB, available to each UDF sandbox process. Null uses the sandbox default. (wire: memoryLimitMib)
pool_sizeintegerCommand pool size for executable_pool UDFs. (wire: poolSize)
return_typestringClickHouse data type of the returned value. (wire: returnType)
runtimestringRuntime used to execute the UDF command. (python3.11, native)
sandbox_typestringSandbox isolation level. (basic, netenable) (wire: sandboxType)
sandbox_versionstringSandbox runtime version. (v1, v2, v3) (wire: sandboxVersion)
send_chunk_headerbooleanWhether ClickHouse sends a row-count chunk header. (wire: sendChunkHeader)
statusstringBuild state of this UDF version. (building, error, ready)
typestringExecutable UDF type. (executable, executable_pool)
updated_atstring (date-time)Last-update timestamp. (wire: updatedAt)
versionintegerVersion number of the UDF.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectfunction_name, organization_idDisclaimer: This beta endpoint is evolving; the API contract may change. <br /><br /> Returns the latest version of a UDF.
listselectorganization_idcursor, limitDisclaimer: This beta endpoint is evolving; the API contract may change. <br /><br /> Returns the latest version of each UDF in the organization.
createinsertorganization_id, upload_id, runtime, arguments, return_type, type, function_nameDisclaimer: This beta endpoint is evolving; the API contract may change. <br /><br /> Creates a new UDF. See [User-defined functions in Cloud](https:​//clickhouse.com/docs/products/cloud/features/sql-console-features/user-defined-functions).
deletedeletefunction_name, organization_idDisclaimer: This beta endpoint is evolving; the API contract may change. <br /><br /> Deletes every version of a UDF and detaches it from all services. Removal from services completes asynchronously.

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.

NameDatatypeDescription
function_namestringName of the UDF. (wire: functionName)
organization_idstringClickHouse Cloud organization ID. Resolved from the CLICKHOUSE_ORG_ID environment variable when it is set (x-stackQL-envVar); otherwise it must be supplied on every query as WHERE organization_id = <uuid>. A WHERE value always takes precedence over the environment. (x-stackQL-envVar: CLICKHOUSE_ORG_ID)
cursorstringCursor returned in pagination.nextCursor from the previous page.
limitintegerMaximum number of records to return per page. Defaults to 100. Maximum is 100.

SELECT examples

Disclaimer: This beta endpoint is evolving; the API contract may change. <br /><br /> Returns the latest version of a UDF.

SELECT
function_name,
return_name,
arguments,
command_read_timeout,
command_write_timeout,
created_at,
error,
format,
max_command_execution_time,
memory_limit_mib,
pool_size,
return_type,
runtime,
sandbox_type,
sandbox_version,
send_chunk_header,
status,
type,
updated_at,
version
FROM clickhouse.udfs.functions
WHERE function_name = '{{ function_name }}' -- required
AND organization_id = '{{ organization_id }}' -- required unless CLICKHOUSE_ORG_ID is set
;

INSERT examples

Disclaimer: This beta endpoint is evolving; the API contract may change. <br /><br /> Creates a new UDF. See [User-defined functions in Cloud](https:​//clickhouse.com/docs/products/cloud/features/sql-console-features/user-defined-functions).

INSERT INTO clickhouse.udfs.functions (
upload_id,
runtime,
arguments,
return_type,
return_name,
command_read_timeout,
command_write_timeout,
memory_limit_mib,
send_chunk_header,
format,
sandbox_type,
sandbox_version,
type,
pool_size,
max_command_execution_time,
function_name,
organization_id
)
SELECT
'{{ upload_id }}' /* required */,
'{{ runtime }}' /* required */,
'{{ arguments }}' /* required */,
'{{ return_type }}' /* required */,
'{{ return_name }}',
{{ command_read_timeout }},
{{ command_write_timeout }},
'{{ memory_limit_mib }}',
{{ send_chunk_header }},
'{{ format }}',
'{{ sandbox_type }}',
'{{ sandbox_version }}',
'{{ type }}' /* required */,
'{{ pool_size }}',
'{{ max_command_execution_time }}',
'{{ function_name }}' /* required */,
'{{ organization_id }}'
RETURNING
request_id,
result,
status
;

DELETE examples

Disclaimer: This beta endpoint is evolving; the API contract may change. <br /><br /> Deletes every version of a UDF and detaches it from all services. Removal from services completes asynchronously.

DELETE FROM clickhouse.udfs.functions
WHERE function_name = '{{ function_name }}' --required
AND organization_id = '{{ organization_id }}' --required unless CLICKHOUSE_ORG_ID is set
;