ALTER FUNCTION (DMF) | Snowflake Documentation (original) (raw)
Modifies the properties of an existing data metric function (DMF).
To make any other changes to a DMF, you must drop the function using a DROP FUNCTION command and recreate the DMF.
See also:
Syntax¶
ALTER FUNCTION [ IF EXISTS ] ( TABLE( [ , ... ] ) [ , TABLE( [ , ... ] ) ] ) RENAME TO
ALTER FUNCTION [ IF EXISTS ] ( TABLE( [ , ... ] ) [ , TABLE( [ , ... ] ) ] ) SET SECURE
ALTER FUNCTION [ IF EXISTS ] ( TABLE( [ , ... ] ) [ , TABLE( [ , ... ] ) ] ) UNSET SECURE
ALTER FUNCTION [ IF EXISTS ] ( TABLE( [ , ... ] ) [ , TABLE( [ , ... ] ) ] ) SET COMMENT = ''
ALTER FUNCTION [ IF EXISTS ] ( TABLE( [ , ... ] ) [ , TABLE( [ , ... ] ) ] ) UNSET COMMENT
ALTER FUNCTION [ IF EXISTS ] ( TABLE( [ , ... ] ) [ , TABLE( [ , ... ] ) ] ) SET TAG = '' [ , = '' ... ]
ALTER FUNCTION [ IF EXISTS ] ( TABLE( [ , ... ] ) [ , TABLE( [ , ... ] ) ] ) UNSET TAG [ , ... ]
Parameters¶
_name_
Specifies the identifier for the DMF to alter.
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.
For more information, see Identifier requirements.
TABLE( _argdatatype_ [ , ... ] ) [ , TABLE( <arg_data_type> [ , ... ] ) ]
Specifies the data type of the column arguments for the DMF. The data types are necessary because DMFs support name overloading, where two DMFs in the same schema can have the same name. The data types of the arguments are used to identify the DMF you want to alter.
RENAME TO _newname_
Specifies the new identifier for the DMF; 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 UDF, don’t 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
- The destination database and/or schema must already exist. In addition, an object with the same name cannot already exist in the new location; otherwise, the statement returns an error.
- Moving an object to a managed access schema is prohibited unless the object owner (that is, the role that has the OWNERSHIP privilege on the object) also owns the target schema.
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 DMF:
SECURE
Specifies whether a function is secure. For more information, see Protecting Sensitive Information with Secure UDFs and Stored Procedures.
COMMENT = '_stringliteral_'
Adds a comment or overwrites the existing comment for the function. The value you specify is displayed in the DESCRIPTION
column in the SHOW FUNCTIONS and SHOW USER FUNCTIONS output.
TAG _tagname_ = '_tagvalue_' [ , _tagname_ = '_tagvalue_' , ... ]
Specifies the tag name and the tag string value.
The tag value is always a string, and the maximum number of characters for the tag value is 256.
For information about specifying tags in a statement, see Tag quotas for objects and columns.
UNSET ...
Specifies the properties to unset for the function, which resets them to the defaults.
SECURE
COMMENT
TAG _tagname_ [ , _tagname_ ... ]
Access control requirements¶
A role used to execute this operation must have the followingprivileges at a minimum:
Privilege | Object | Notes |
---|---|---|
OWNERSHIP | Data metric function | |
APPLY | Tag | Enables setting a tag on the DMF. |
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¶
- If you want to update an existing data metric function and need to see the current definition of the function, run theDESCRIBE FUNCTION (DMF) command or call the GET_DDL function.
- Regarding metadata:
Attention
Customers should ensure that no personal data (other than for a User object), sensitive data, export-controlled data, or other regulated data is entered as metadata when using the Snowflake service. For more information, see Metadata fields in Snowflake.
Example¶
You can use the ALTER FUNCTION command to make a DMF secure. For more information about what it means for a function to be secure, seeProtecting Sensitive Information with Secure UDFs and Stored Procedures.
ALTER FUNCTION governance.dmfs.count_positive_numbers( TABLE( NUMBER, NUMBER, NUMBER )) SET SECURE;