Create External User Defined Function for Verify
This section describes the requirements for creating external defined function named ‘verify’ by using these examples.
Below important headers must be passed in external defined function:
- headers-api-key: It expects DIS API's production environment key.
- headers-api-secret: It expects DIS API's production environment secret.
- application: Snowflake users need to define
dis-geoaddressing
.
There are three types of verify methods:
- With (address, country) as a parameter.
- With (array) as a parameter.
- With (object) as a parameter.
Currently, verify is supported for input addresses in five address formats: Format 1,
Format 2, Format 3, Format 4, and Format 5. We recommend using Format 5.
Note: The user
should replace ‘<<DIS API KEY>>’ and ‘<<DIS API
SECRET>>’ with own API Key and API Secret.
Note: Country is a mandatory input for Verify
using any Format, failing to provide a Country will lead to unsuccessful Verify
operation.
Note: All the Formats support secure User
Defined Functions. For more information see Protecting Sensitive
Information with Secure UDF's
Type 1
This script is used for input addresses of Format 1 type and expects address
and country as input parameters.
create or replace external function verify(addressLines string ,country string )
returns variant
IMMUTABLE
api_integration = API_INTEGRATION
HEADERS = ('headers-api-key'= '<<DIS API KEY>>', 'headers-api-secret'='<<DIS API SECRET>>',
'application'='dis-geoaddressing')
MAX_BATCH_ROWS = 25
as 'https://9a3cydoxrc.execute-api.us-east-1.amazonaws.com/v1/geocode'
Type 2
This script is used for input addresses of Format 2, Format 3, and Format 4
types and expects array as an input parameter.
create or replace external function verify(address array)
returns variant
IMMUTABLE
api_integration = API_INTEGRATION
HEADERS = ('headers-api-key'= '<<DIS API KEY>>', 'headers-api-secret'='<<DIS API SECRET>>','application'='dis-geoaddressing')
MAX_BATCH_ROWS = 25
as 'https://9a3cydoxrc.execute-api.us-east-1.amazonaws.com/v1/geocode';
Type 3
This script is used for input addresses of Format 5 type and expects JSON object as an input parameter.create or replace external function verify(address object)
returns variant
IMMUTABLE
api_integration = API_INTEGRATION
HEADERS = ('headers-api-key'= '<<DIS API KEY>>', 'headers-api-secret'='<<DIS API SECRET>>',
'application'='dis-geoaddressing')
MAX_BATCH_ROWS = 25
as 'https://9a3cydoxrc.execute-api.us-east-1.amazonaws.com/v1/geocode';
FigureCreating External User-Defined Function of Type3