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#

  1. Set up your license key using Databricks secrets. See Databricks License Key Set Up.

  2. Fill in the required fields indicated by (*).

  3. Click Run all to run the notebook.

  4. 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

../../_images/Databricks-GAV-Verify-Single-Example-Input-1.png ../../_images/Databricks-GAV-Verify-Single-Example-Input-2.png

Output Example

../../_images/Databricks-GAV-Verify-Single-Example-Output.png

Input Parameters#

The following table describes the input parameters for the Verify Single Address notebook.

Parameter

Data Type

Description

Example

License

STRING

Required.
The License Key with Credits issued by Melissa.

Get it here.

See more information on license key set up.

Options

STRING

[OptionName:Parameter], separated by commas (,).

See more information about endpoint options.

USPreferredCityNames:on,
USStandardizationType:short

Organization Name

STRING

The organization name associated with the address record.

Last Name

STRING

US Only.
For addresses missing a secondary like a suite or apartment, the last name can be used to append that information for residential addresses.

AddressLine1

STRING

Required.
The input field for the address.

This should contain the delivery address information (house number, thoroughfare, building, suite, etc.) but should not contain locality information (locality, administrative area, postal code, etc.), which have their own inputs.

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.

This depends on the Locality and DependentLocality elements.

Dependent Locality

STRING

Urbanization.

The smaller population center data element.
This depends on the Locality element. In terms of US addresses, this element applies only to Puerto Rican addresses. It is used to break ties when a ZIP Code™ is linked to multiple instances of the same address.

Locality

STRING

Required.
City, Municipality.

The most common population center data element.

Rancho Santa Margarita

Sub-Administrative Area

STRING

County.

The smallest geographic data element.

Administrative Area

STRING

Required.
State, Province.

The most common geographic data element.

CA

Postal Code

STRING

Required.
ZIP, Postcode.

The complete postal code for a particular delivery point.
If all three elements are provided and the PostalCode is incorrect, it can be corrected using the data from Locality and AdministrativeArea.

92688

Sub-National Area

STRING

The administrative region within a country on an arbitrary level below that of the sovereign state.

Country

STRING

Required.
The country name, abbreviation, or code.

Output Table Name

STRING

The output table name.

A new table will be created if it doesn’t exist.
If the table exists, its structure must remain unchanged.

Output Table Fields

STRING

Case-sensitive.

Only valid when Output Table Name is provided.

Select fields for the output table. If left blank or Select All, all fields will output.
To output chosen fields, ensure Select All is deselected.

RecordID,
Results,
FormattedAddress,
Organization,
AddressLine1,
AddressLine2,
AddressLine3,
AddressLine4,
AddressLine5,
AddressLine6,
AddressLine7,
AddressLine8,
SubPremises,
DoubleDependentLocality,
DependentLocality,
Locality,
SubAdministrativeArea,
AdministrativeArea,
PostalCode,
PostalCodeType,
AddressType,
AddressKey,
SubNationalArea,
CountryName,
CountryISO3166_1_Alpha2,
CountryISO3166_1_Alpha3,
CountryISO3166_1_Numeric,
CountrySubdivisionCode,
Thoroughfare,
ThoroughfarePreDirection,
ThoroughfareLeadingType,
ThoroughfareName,
ThoroughfareTrailingType,
ThoroughfarePostDirection,
DependentThoroughfare,
DependentThoroughfarePreDirection,
DependentThoroughfareLeadingType,
DependentThoroughfareName,
DependentThoroughfareTrailingType,
DependentThoroughfarePostDirection,
Building,
PremisesType,
PremisesNumber,
SubPremisesType,
SubPremisesNumber,
PostBox,
Latitude,
Longitude,
DeliveryIndicator,
MelissaAddressKey,
MelissaAddressKeyBase,
PostOfficeLocation,
SubPremiseLevel,
SubPremiseLevelType,
SubPremiseLevelNumber,
SubBuilding,
SubBuildingType,
SubBuildingNumber,
UTC,
DST,
DeliveryPointSuffix,
CensusKey,
CBSACode,
CBSADivisionCode,
CBSADivisionLevel,
CBSADivisionTitle,
CBSALevel,
CBSATitle,
CarrierRoute,
CensusBlock,
CensusTract,
CongressionalDistrict,
CountyFIPS,
CountySubdivisionCode,
CountySubdivisionName,
DeliveryPointCheckDigit,
DeliveryPointCode,
PlaceCode,
PlaceName,
StateDistrictLower,
StateDistrictUpper,
UnifiedSchoolDistrictCode,
UnifiedSchoolDistrictName

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.
Record identifier, primary key.

organization

STRING

The organization name associated with the address record.

last_name

STRING

US Only.
For addresses missing a secondary like a suite or apartment, the last name can be used to append that information for residential addresses.

address_line_1

STRING

Required.
The input field for the address.

This should contain the delivery address information (house number, thoroughfare, building, suite, etc.) but should not contain locality information (locality, administrative area, postal code, etc.), which have their own inputs.

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.

This depends on the Locality and DependentLocality elements.

dependent_locality

STRING

Urbanization.

The smaller population center data element.
This depends on the Locality element. In terms of US addresses, this element applies only to Puerto Rican addresses. It is used to break ties when a ZIP Code™ is linked to multiple instances of the same address.

locality

STRING

Required.
City, Municipality.

The most common population center data element.

sub_administrative_area

STRING

County.

The smallest geographic data element.

administrative_area

STRING

Required.
State, Province.

The most common geographic data element.

postal_code

STRING

Required.
ZIP, Postcode.

The complete postal code for a particular delivery point.
If all three elements are provided and the PostalCode is incorrect, it can be corrected using the data from Locality and AdministrativeArea.

sub_national_area

STRING

The administrative region within a country on an arbitrary level below that of the sovereign state.

country

STRING

Required.
The country name, abbreviation, or code.

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, and USE CATALOG privileges 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.
The License Key with Credits issued by Melissa.

Get it here.

See more information on license key set up.

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.

options
[OptionName:Parameter], separated by commas (,).

See more information about endpoint options.

USPreferredCityNames:on,
USStandardizationType:short

input_table

STRING

Required.
Name of the input table.

catalog.schema.input_table_name

output_table

STRING

Required.
The output table name.

A new table will be created if it doesn’t exist.
If the table exists, its structure must remain unchanged.

catalog.schema.output_table_name

output_columns

STRING

Case-sensitive.

Fields in the output table; fields separated by commas (,) if not ‘ALL’.
Field names must match the available output column names in the example list. Use ALL to include every available field.
If omitted, see Default Output Fields.

RecordID,
InLastName,
InOrganization,
InAddressLine1,
InAddressLine2,
InAddressLine3,
InAddressLine4,
InAddressLine5,
InAddressLine6,
InAddressLine7,
InAddressLine8,
InDoubleDependentLocality,
InDependentLocality,
InLocality,
InSubAdministrativeArea,
InAdministrativeArea,
InPostalCode,
InSubNationalArea,
InCountry,
Results,
FormattedAddress,
Organization,
AddressLine1,
AddressLine2,
AddressLine3,
AddressLine4,
AddressLine5,
AddressLine6,
AddressLine7,
AddressLine8,
SubPremises,
DoubleDependentLocality,
DependentLocality,
Locality,
SubAdministrativeArea,
AdministrativeArea,
PostalCode,
PostalCodeType,
AddressType,
AddressKey,
SubNationalArea,
CountryName,
CountryISO3166_1_Alpha2,
CountryISO3166_1_Alpha3,
CountryISO3166_1_Numeric,
CountrySubdivisionCode,
Thoroughfare,
ThoroughfarePreDirection,
ThoroughfareLeadingType,
ThoroughfareName,
ThoroughfareTrailingType,
ThoroughfarePostDirection,
DependentThoroughfare,
DependentThoroughfarePreDirection,
DependentThoroughfareLeadingType,
DependentThoroughfareName,
DependentThoroughfareTrailingType,
DependentThoroughfarePostDirection,
Building,
PremisesType,
PremisesNumber,
SubPremisesType,
SubPremisesNumber,
PostBox,
Latitude,
Longitude,
DeliveryIndicator,
MelissaAddressKey,
MelissaAddressKeyBase,
PostOfficeLocation,
SubPremiseLevel,
SubPremiseLevelType,
SubPremiseLevelNumber,
SubBuilding,
SubBuildingType,
SubBuildingNumber,
UTC,
DST,
DeliveryPointSuffix,
CensusKey,
Extras,
JSON_Response,
Timestamp

log_to_table

BOOLEAN

Enable or disable logs to facilitate troubleshooting in case of any issues.
- False (Default): No action will be taken. The notebook will process with no log writes.
- True: Enable event, batch progress, and error logging.

True

log_table

STRING

Name of the log table. Only valid when log_to_table = True.

catalog.schema.log_table_name

duplicate_check

BOOLEAN

Enable or disable several checks for duplicate RecordID.
- False (Default): No action will be taken. The notebook will process records coming from the input source as is.
- True: Enable several checks for duplicate RecordID. When enabled, a repeated RecordID stops the run before anything is sent, and records already in the output table are skipped. This makes it safe to rerun after a failure without submitting the same records to the service again.

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

  • AV2X denotes an address that has been verified to the highest possible level with the reference data.

  • AV1X denotes a partially verified address, but NOT to the highest level possible with the reference data.

  • The second number indicates the level of verification. There are five levels:

    ../../_images/GAV-Reference-Guide-Interpreting-Results-AV-Codes.png

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

AS09

The address is in a non-supported country.

Contact your CSR to add new countries.

AV25

The address has been verified to the SubPremise (Suite) or PO Box Level, which is the highest level possible with the reference data.

Good

AV24

The address has been verified to the Premise (House or Building) Level, which is the highest level possible with the reference data.

Good

AV23

The address has been verified to the Thoroughfare (Street) Level, which is the highest level possible with the reference data.

Good

AV22

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.

AV14

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.

AV13

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.

AV12

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.

AV11

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.