Global Address Verification Notebook: Databricks Reference Guide#
Notebook Configuration#
Follow the instructions to get the notebook and details about installation in Notebook Installation.
Verify Single Address#
The Verify Single Address notebook validates and standardizes an individual address using the Global Address Verification API. It can return the response as JSON or write selected response fields to an output table.
Example#
Set up your license key using Databricks secrets. See Databricks License Key Set Up.
Fill in the required fields indicated by (*).
Click
Run allto run the notebook.The JSON response will be displayed in the View Results notebook section. If an output table is named, the result will append to the table.
Input Example
Output Example
Input Parameters#
The following table describes the input parameters for the Verify Single Address notebook.
Parameter |
Data Type |
Description |
Example |
|---|---|---|---|
License |
STRING |
Required. |
|
Options |
STRING |
[OptionName:Parameter], separated by commas (,). |
USPreferredCityNames:on, |
Organization Name |
STRING |
The organization name associated with the address record. |
|
Last Name |
STRING |
US Only. |
|
AddressLine1 |
STRING |
Required. |
22382 Avenida Empresa |
AddressLine2 |
STRING |
The input field for the address. |
|
AddressLine3 |
STRING |
The input field for the address. |
|
AddressLine4 |
STRING |
The input field for the address. |
|
AddressLine5 |
STRING |
The input field for the address. |
|
AddressLine6 |
STRING |
The input field for the address. |
|
AddressLine7 |
STRING |
The input field for the address. |
|
AddressLine8 |
STRING |
The input field for the address. |
|
Double Dependent Locality |
STRING |
The smallest population center data element. |
|
Dependent Locality |
STRING |
Urbanization. |
|
Locality |
STRING |
Required. |
Rancho Santa Margarita |
Sub-Administrative Area |
STRING |
County. |
|
Administrative Area |
STRING |
Required. |
CA |
Postal Code |
STRING |
Required. |
92688 |
Sub-National Area |
STRING |
The administrative region within a country on an arbitrary level below that of the sovereign state. |
|
Country |
STRING |
Required. |
|
Output Table Name |
STRING |
The output table name. |
|
Output Table Fields |
STRING |
Case-sensitive. |
RecordID, |
Verify Multiple Addresses#
The Verify Multiple Addresses notebook processes address records in batches, validating and standardizing key components using the Global Address Verification API.
It can handle tables of any size, returning the results in a specified output table and supports optional fields for flexible, accurate address validation.
Requirements#
To use this notebook, you need to prepare an input table in Databricks beforehand referencing our default input fields below.
Input Fields#
Column Name |
Data Type |
Description |
|---|---|---|
record_id |
STRING |
Required. |
organization |
STRING |
The organization name associated with the address record. |
last_name |
STRING |
US Only. |
address_line_1 |
STRING |
Required. |
address_line_2 |
STRING |
The input field for the address. |
address_line_3 |
STRING |
The input field for the address. |
address_line_4 |
STRING |
The input field for the address. |
address_line_5 |
STRING |
The input field for the address. |
address_line_6 |
STRING |
The input field for the address. |
address_line_7 |
STRING |
The input field for the address. |
address_line_8 |
STRING |
The input field for the address. |
double_dependent_locality |
STRING |
The smallest population center data element. |
dependent_locality |
STRING |
Urbanization. |
locality |
STRING |
Required. |
sub_administrative_area |
STRING |
County. |
administrative_area |
STRING |
Required. |
postal_code |
STRING |
Required. |
sub_national_area |
STRING |
The administrative region within a country on an arbitrary level below that of the sovereign state. |
country |
STRING |
Required. |
Python Notebook Setup#
The step-by-step example below shows how to use the notebook. Replace with your values.
Step 0 - Prepare an input table
Assume that the input table has the signature below:
CREATE TABLE IF NOT EXISTS <catalog>.<schema>.<input_table> ( RecId INT, OrganizationName STRING, Address1 STRING, Address2 STRING, Address3 STRING, Address4 STRING, Address5 STRING, Address6 STRING, Address7 STRING, Address8 STRING, City STRING, County STRING, State STRING, PostalCode STRING, Country STRING );
This input table has different column names from the Input Fields. Mapping column names in Step 2 is necessary for the program to get the correct parameters.
Attention
Make sure your input table contains unique RecordID before running the next script. See more about Batch Processing Best Practices.
Step 1 - Required Privileges
Ensure you have the necessary access to the input table and output table including
SELECT,INSERT,UPDATE,USE SCHEMA, andUSE CATALOGprivileges for the tables involved.Step 2 - Map Input Columns with the Default Input Fields
Set the required parameters and map your input columns to our Input Fields.
Check Input Parameters for more information.
from melissadatacloudapi_databricks import Config, GLOBAL_ADDRESS_VERIFICATION, run config = Config( license_key=LICENSE_KEY, input_table="<catalog>.<schema>.<input_table>", output_table="<catalog>.<schema>.<output_table>", # Map your input columns with our input fields, replace with your actual column names # For optional columns, leave the field as "". parameter_mapping={ "record_id": "RecId", "address_line_1": "Address1", "locality": "City", "administrative_area": "State", "postal_code": "PostalCode", "country": "Country", "last_name": "", "organization": "OrganizationName", "address_line_2": "Address2", "address_line_3": "Address3", "address_line_4": "Address4", "address_line_5": "Address5", "address_line_6": "Address6", "address_line_7": "Address7", "address_line_8": "Address8", "double_dependent_locality": "", "dependent_locality": "", "sub_administrative_area": "County", "sub_national_area": "", }, request_parameters={ "options": "", }, output_columns="<field_1,field_2>", log_to_table=False, log_table="<catalog>.<schema>.<log_table>", duplicate_check=False, )
Step 3 - Call run() to verify your data
run(GLOBAL_ADDRESS_VERIFICATION, config, spark=spark, dbutils=dbutils) # Output table view display( spark.sql( f"SELECT * FROM {config.output_table} ORDER BY TRY_CAST(RecordID AS BIGINT), RecordID LIMIT 1000" ) )
Input Parameters#
The following table describes the input parameters for the Verify Multiple Addresses notebook.
Parameter |
Data Type |
Description |
Example |
|---|---|---|---|
license_key |
STRING |
Required. |
|
parameter_mapping |
Connects each Melissa field to a column in your input table. See Input Fields. |
||
request_parameters |
Sent once with every batch, applied to every record. |
USPreferredCityNames:on, |
|
input_table |
STRING |
Required. |
catalog.schema.input_table_name |
output_table |
STRING |
Required. |
catalog.schema.output_table_name |
output_columns |
STRING |
Case-sensitive. |
RecordID, |
log_to_table |
BOOLEAN |
Enable or disable logs to facilitate troubleshooting in case of any issues. |
True |
log_table |
STRING |
Name of the log table. Only valid when log_to_table = |
catalog.schema.log_table_name |
duplicate_check |
BOOLEAN |
Enable or disable several checks for duplicate RecordID. |
True |
Default Output Fields#
If output_columns is an empty string or not provided, output table will have a default schema as below.
Column Name |
Data Type |
|---|---|
RecordID |
STRING |
InLastName |
STRING |
InOrganization |
STRING |
InAddressLine1 |
STRING |
InAddressLine2 |
STRING |
InAddressLine3 |
STRING |
InAddressLine4 |
STRING |
InAddressLine5 |
STRING |
InAddressLine6 |
STRING |
InAddressLine7 |
STRING |
InAddressLine8 |
STRING |
InDoubleDependentLocality |
STRING |
InDependentLocality |
STRING |
InLocality |
STRING |
InSubAdministrativeArea |
STRING |
InAdministrativeArea |
STRING |
InPostalCode |
STRING |
InSubNationalArea |
STRING |
InCountry |
STRING |
MelissaAddressKey |
STRING |
MelissaAddressKeyBase |
STRING |
Results |
STRING |
FormattedAddress |
STRING |
CountryName |
STRING |
Latitude |
STRING |
Longitude |
STRING |
JSON_Response |
STRING |
Timestamp |
TIMESTAMP |
Result Codes#
For the full list of result codes returned by Global Address Verification Notebook: Databricks, please visit Result Codes - Global Address Verification: Databricks.
Interpreting Results#
The Results field returned back by the service will tell all the status, error and change information about the output address returned back to you.
They are returned as a comma-delimited string of 4-character alpha-numeric codes, e.g. AC02,AS01 or AE01.
The results are split into four main categories:
AV Codes |
|
AE Codes |
These are error codes that will tell you what type of error we encountered. |
AC Codes |
These are change codes that will tell you which address pieces we changed from the input to the output. They include field that were blank in the input and added in the output. |
GS & GE Codes |
For the users who get geocoding information, this will tell you to what precision level the latitude and longitude appended are. |
The SE## and GE## codes (Transmission Service Error and General Transmission Error) are used to signify more general errors, and are returned under the key TransmissionResults in the outermost level of our responses.
The concept behind the result codes are that the service will include a full list of delimited result codes, many of which may not be important to you. As a user, you should decide what codes define a good address for you and use a string.Contains search to look for those codes. If you find it, you have a good address. If you don’t, then you have a bad address. You can also cascade them into 3 or more condition layers. Here is a common example:
Result Code Cloud API Error Example:
If(Results.Contains("AV23") or Results.Contains("AV24") or Results.Contains("AV25"))
{ /*Handle Good Address*/ }
Else if(Results.Contains("AV22") or Results.Contains("AV14") or Results.Contains("AV13"))
{ /*Handle Suspect Address*/ }
Else
{ /*Handle Bad Address*/ }
Code |
Description |
Recommendation |
|---|---|---|
|
The address is in a non-supported country. |
Contact your CSR to add new countries. |
|
The address has been verified to the SubPremise (Suite) or PO Box Level, which is the highest level possible with the reference data. |
Good |
|
The address has been verified to the Premise (House or Building) Level, which is the highest level possible with the reference data. |
Good |
|
The address has been verified to the Thoroughfare (Street) Level, which is the highest level possible with the reference data. |
Good |
|
The address has been verified to the Locality (City) Level, which is the highest level possible with the reference data. |
Medium. Only locality data was available, odds on quality is dependent on source of input. |
|
The address has been partially verified to the Premise (House or Building) Level, which is NOT the highest level possible with the reference data. |
Medium. Most of the address was good, just bad/missing suite. |
|
The address has been partially verified to the Thoroughfare (Street) Level, which is NOT the highest level possible with the reference data. |
Medium. Most of the address was good, house number not verified. |
|
The address has been partially verified to the Locality (City) Level, which is NOT the highest level possible with the reference data. |
Bad. Could not verify the address but found a good locality value. |
|
The address has been partially verified to the Administrative Area (State) Level, which is NOT the highest level possible with the reference data. |
Bad. Could not verify the address but found a good administrative area value. |