Step 4: Create the External Function for GCP in Snowflake¶
These instructions show how to create an external function database object in Snowflake. This database object stores information about the remote service, such as the parameters that the remote service accepts.
In this Topic:
Create the External Function Database Object¶
You should be in a Snowflake web interface session.
Paste the command CREATE EXTERNAL FUNCTION. The command looks similar to the following:
create or replace external function <external_function_name>(<parameters>) returns variant api_integration = <api_integration_name> as '<function_URL>' ;
<external_function_name>with a unique function name (e.g.
Record the function name in the “External Function Name” field in the worksheet.
<parameters>with the names and SQL data types of the parameters, if any. For example:
a integer, b varchar.
The parameters must correspond to the parameters expected by the remote service. The parameter names do not need to match, but the data types need to be compatible.
Record the parameter name and data types in the “External Function Name” field in the worksheet.
api_integrationclause, replace the
<api_integration_name>with the value in the “API Integration Name” field in the worksheet.
<function_URL>with the value in the “Gateway Base URL” field in the worksheet, followed by a slash (
/) and the value in the “Path Suffix” field in the worksheet.
The URL should look similar to:
If you have not already done so, then execute the
CREATE EXTERNAL FUNCTIONcommand that you typed above.
You should now be able to call your external function to verify that it works correctly. For details, see Calling an External Function for GCP.
Snowflake strongly recommends setting a security policy on the Google Cloud API Gateway: