ALTER FUNCTION (Snowpark Container Services) (original) (raw)

Modifies the properties of an existing service function.

To make any other changes to a service function, you must drop the function (using DROP FUNCTION (Snowpark Container Services)) and then recreate it.

See also:

Service functions, CREATE FUNCTION, DESC FUNCTION, DROP FUNCTION

Syntax

ALTER FUNCTION [ IF EXISTS ] ( [ , ... ] ) RENAME TO

ALTER FUNCTION [ IF EXISTS ] ( [ , ... ] ) SET CONTEXT_HEADERS = ( [ , ...] )

ALTER FUNCTION [ IF EXISTS ] ( [ , ... ] ) SET MAX_BATCH_ROWS =

ALTER FUNCTION [ IF EXISTS ] ( [ , ... ] ) SET MAX_BATCH_RETRIES =

ALTER FUNCTION [ IF EXISTS ] ( [ , ... ] ) SET ON_BATCH_FAILURE = { ABORT | RETURN_NULL }

ALTER FUNCTION [ IF EXISTS ] ( [ , ... ] ) SET BATCH_TIMEOUT_SECS =

ALTER FUNCTION [ IF EXISTS ] ( [ , ... ] ) SET COMMENT = ''

ALTER FUNCTION [ IF EXISTS ] ( [ , ... ] ) SET SERVICE = '' ENDPOINT = ''

ALTER FUNCTION [ IF EXISTS ] ( [ , ... ] ) UNSET { CONTEXT_HEADERS | MAX_BATCH_ROWS | MAX_BATCH_RETRIES | ON_BATCH_FAILURE | BATCH_TIMEOUT_SECS | COMMENT }

Parameters

_name_

Specifies the identifier for the service function to alter. The identifier can contain the schema name and database name, as well as the function name. If the identifier contains spaces or special characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case sensitive.

_argdatatype_ [ , ... ]

Specifies the arguments/input data types for the service function.

If the function accepts arguments, then the ALTER command must specify the argument types because functions support name overloading (that is, two functions in the same schema can have the same name), and the argument types are used to identify the function.

RENAME TO _newname_

Specifies the new identifier for the service function; the combination of the identifier and existing argument data types must be unique for the schema.

For more information, see Identifier requirements.

Note

When specifying the new name for the service function, do not specify argument data types or parentheses; specify only the new name.

You can move the object to a different database and/or schema while optionally renaming the object. To do so, specify a qualified _newname_ value that includes the new database and/or schema name in the form_dbname_._schemaname_._objectname_ or _schemaname_._objectname_, respectively.

Note

When an object is renamed, other objects that reference it must be updated with the new name.

SET ...

Specifies the properties to set for the function:

COMMENT = '_stringliteral_'

Specifies a comment for the function, which is displayed in the DESCRIPTION column in the SHOW FUNCTIONS and SHOW USER FUNCTIONSoutput.

SERVICE = '<service_name>' ENDPOINT = '<endpoint_name>'

Specifies the service name and the endpoint name as defined in the service specification.

CONTEXT_HEADERS = ( _contextfunction1_ [ , _contextfunction2_ ... ] )

It allows binding Snowflake context function results to HTTP headers.

Each value must be the name of a context function. Don’t include quote marks around the names.

More details about this parameter are in CREATE FUNCTION (Snowpark Container Services).

MAX_BATCH_ROWS = _integer_

Specifies the batch size when sending data to a service to increase concurrency

MAX_BATCH_RETRIES = _integer_

Specifies the number of times you want Snowflake to retry a failed batch.

ON_BATCH_FAILURE = { ABORT | RETURN_NULL }

Specifies the behavior of the function after Snowflake reaches the maximum number of retries processing the batch.

BATCH_TIMEOUT_SECS = _integer_

Specifies the maximum duration for processing a single batch of rows, including retries (and polling for async function requests), after which Snowflake should terminate the batch request.

Acceptable Values: greater than 0 and less than or equal to 604800 seconds (7 days).

UNSET ...

Specifies the properties to unset for the function, which resets them to the defaults. Note that you can’t unset the service endpoint.

Access control requirements

A role used to execute this operation must have the followingprivileges at a minimum:

Privilege Object Notes
OWNERSHIP Function
USAGE Service endpoint Usage on a service endpoint is granted to service roles defined in the service specification. You then grant the service role to the role altering the service function. This privilege is required if altering a service endpoint.

The USAGE privilege on the parent database and schema are required to perform operations on any object in a schema.

For instructions on creating a custom role with a specified set of privileges, see Creating custom roles.

For general information about roles and privilege grants for performing SQL actions onsecurable objects, see Overview of Access Control.

Usage notes

Examples

Rename a service function:

ALTER FUNCTION my_echo_udf(VARCHAR) RENAME TO my_echo_udf_temp;

Set a comment for a service function:

ALTER FUNCTION my_echo_udf(VARCHAR) SET COMMENT = 'some comment';

Set the maximum number of rows per batch for a service function:

ALTER FUNCTION my_echo_udf(number) SET MAX_BATCH_ROWS = 100;

Set the CURRENT_USER context header for a service function:

ALTER FUNCTION my_echo_udf(VARCHAR) SET CONTEXT_HEADER = (CURRENT_USER);

Unset MAX_BATCH_ROWS for a service function:

ALTER FUNCTION my_echo_udf(VARCHAR) UNSET MAX_BATCH_ROWS;