Categories:

DDL for User-Defined Functions, External Functions, and Stored Procedures

# ALTER EXTERNAL FUNCTION¶

Modifies the properties of an existing external function.

## Syntax¶

ALTER FUNCTION [ IF EXISTS ] <name> ( [ <arg_data_type> , ... ] ) SET COMMENT = '<string_literal>'

ALTER FUNCTION [ IF EXISTS ] <name> ( [ <arg_data_type> , ... ] ) SET API_INTEGRATION = <api_integration_name>

ALTER FUNCTION [ IF EXISTS ] <name> ( [ <arg_data_type> , ... ] )
SET HEADERS = ( [ '<header_1>' = '<value>' [ , '<header_2>' = '<value>' ... ] ] )

ALTER FUNCTION [ IF EXISTS ] <name> ( [ <arg_data_type> , ... ] )
SET CONTEXT_HEADERS = ( [ <context_function_1> [ , context_function_2> ...] ] )

ALTER FUNCTION [ IF EXISTS ] <name> ( [ <arg_data_type> , ... ] ) SET MAX_BATCH_ROWS = <integer>

ALTER FUNCTION [ IF EXISTS ] <name> ( [ <arg_data_type> , ... ] ) SET COMPRESSION = <compression_type>

ALTER FUNCTION [ IF EXISTS ] <name> ( [ <arg_data_type> , ... ] ) RENAME TO <new_name>

ALTER FUNCTION [ IF EXISTS ] <name> ( [ <arg_data_type> , ... ] ) SET SECURE

ALTER FUNCTION [ IF EXISTS ] <name> ( [ <arg_data_type> , ... ] ) UNSET { COMMENT | HEADERS | CONTEXT_HEADERS | MAX_BATCH_ROWS | COMPRESSION | SECURE }


## Parameters¶

name:

Specifies the identifier for the function.

The identifier can contain the schema name and database name, as well as the function name.

( [ arg_data_type ] [ , ... ] )

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

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

api_integration_name

This is the name of the API integration object that should be used to authenticate the call to the proxy service.

[ HEADERS = ( '<header_1>' = '<value>' [ , '<header_2>' = '<value>' ... ] ) ]

This clause allows users to attach key-value metadata that is sent with every request.

The value must be a constant string, not an expression.

CONTEXT_HEADERS (...)

This is similar to headers, but instead of allowing only constant strings, it allows binding Snowflake context function results to HTTP headers.

Each value must be the name of a context function. The names should not be quoted.

COMPRESSION = <compression_type>

If this clause is specified, the JSON payload is compressed using the specified format when sent from Snowflake to the proxy service, and when sent back from the proxy service to Snowflake.

For more details about valid values of <compression_type>, see CREATE EXTERNAL FUNCTION.

RENAME TO new_name

Specifies the new identifier for the function.

The identifier does not need to be unique for the schema in which the function is created because functions are identified and resolved by their name and argument types. However, the signature (name and parameter data types) must be unique within the schema.

The name must follow the rules for Snowflake identifiers. For more details, see Identifier Requirements.

Note

When specifying the new name for the external function, do not specify argument data types or parentheses; the function will continue using the same arguments as before.

## Usage Notes¶

• Moving an external function to a managed access schema (using the ALTER EXTERNAL FUNCTION … RENAME TO syntax) is prohibited unless the external function owner (i.e. the role that has the OWNERSHIP privilege on the external function) also owns the target schema.

• There is no UNSET command for API_INTEGRATION. You can change the API_INTEGRATION, but you cannot unset it.

## Examples¶

Rename the function function1 to function2:

ALTER EXTERNAL FUNCTION IF EXISTS function1(number) RENAME TO function2;


Convert a regular function function2 to a secure function:

ALTER EXTERNAL FUNCTION function2(number) SET SECURE;


Rename an external function:

ALTER EXTERNAL FUNCTION function3(number) RENAME TO function3b;