Advanced Topics
Snowflake also publishes a best practice/performance recommendation link that can also provide some options to improve performance.
Note
It is recommended while creating the functions to make them immutable which should improve performance for certain types of queries.
Ensure that you allow enough Cloud Function instances to run in order to handle the queries with large results sets.
Snowflake has the ability to create column masks which can invoke a remote external function. This allows the ease of use and control who can run the functions.
Examples:
CADP
CREATE OR REPLACE MASKING POLICY thales_mask AS (val string) RETURNS string ->
CASE
WHEN CURRENT_ROLE() IN ('ANALYST') THEN thales_cadp_aws_decrypt_char(val)
ELSE val
END;
CT-VL
CREATE OR REPLACE MASKING POLICY thales_cts_mask AS (val string) RETURNS string ->
CASE
WHEN CURRENT_ROLE() IN ('ANALYST') THEN thales_cts_gcp_detokenize_char(val)
ELSE val
END;
For more information, refer to the Snowflake Documentation.