Calling out to an external service from Snowflake with external functions
External functions let Snowflake call out to code running outside its environment (e.g., a cloud provider's serverless compute) via a remote HTTPS endpoint, extending SQL with custom logic that can't be expressed natively. They are defined with CREATE EXTERNAL FUNCTION and rely on an API integration object to securely route requests through a proxy service to the remote endpoint.
1 · Learn the must-know
- An API integration must be created first (CREATE API INTEGRATION) to define the trusted proxy service and allowed endpoint prefixes before an external function can reference it.
- External functions are always scalar: they return exactly one value per input row and cannot be defined as aggregate or table functions.
- Snowflake batches multiple rows into a single HTTPS request/response for efficiency; the remote service must handle the JSON array-of-arrays format Snowflake sends and return results in the same row order.
- The remote service (e.g., a cloud function or Lambda) is invoked over HTTPS through the API Gateway/proxy configured in the API integration, and it must return a well-formed JSON response or the query fails.
- Because each call involves network round-trips, external functions add latency and cost compared to native UDFs/UDTFs, so they should be reserved for logic that truly cannot be done inside Snowflake.
- CREATE EXTERNAL FUNCTION requires specifying the API integration, the remote service URL (AS), and can optionally set
MAX_BATCH_ROWSto control batch size sent per HTTP call.
2 · Check your understanding
A Data Engineer builds a scalar external function named GEOCODE_ADDRESS that calls a proxy service backed by AWS API Gateway and Lambda:
CREATE EXTERNAL FUNCTION geocode_address(addr varchar)
RETURNS VARIANT
API_INTEGRATION = my_api_int
AS 'https://abc123.execute-api.us-east-1.amazonaws.com/prod/geocode';
When the function is called against a table of 500 addresses, Snowflake raises the error "Error parsing JSON response from remote service." The Lambda function currently returns a body shaped as {"result": [<geocoded value>, ...]} for every batch it receives.
What must the remote service return instead so Snowflake can correctly match each output row to its corresponding input row?
What you have tried across SnowPro Advanced Data Engineer's objectives, not a readiness score.
Data Movement28% of the exam*0 of 7 tried
Performance Optimization19% of the exam*0 of 3 tried
Storage and Data Protection14% of the exam*0 of 3 tried
Data Governance14% of the exam*0 of 2 tried
Data Transformation25% of the exam*0 of 7 tried
* Our estimate. Snowflake publishes no section weights.
3 · Keep going
Ready for more? Take a weighted mock or try free practice questions.