SmartMover USA 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 uses the SmartMover API to standardize US addresses, identify moves, and return updated address information when available. 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-SmartMover-Verify-Single-Example-Input-1.png ../../_images/Databricks-SmartMover-Verify-Single-Example-Input-2.png

Output Example

../../_images/Databricks-SmartMover-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.

PAFID

STRING

Required; empty string is accepted.
For Broker accounts, identifies the end user associated with the record. Does not apply to CCOA.

JobID

STRING

Required.
Identifies records belonging to the same list for NCOA reporting. Use the same JobID for all records in one list; this is not a record key.

jobid1234

Options

STRING

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

See more information about endpoint options.

ProcessingType:Standard

Columns

STRING

Requested response columns, separated by commas (,).

See SmartMover request columns.

MoveReturnCode,PrivateMailbox

List Name

STRING

Identifies the current list and is included in SmartMover V3 reports.

customer_list

Company

STRING

Business name.

Melissa

Name Full

STRING

Full name of an individual.

AddressLine1

STRING

Required.
Minimum address location for the name or company contact.

22382 Avenida Empresa

AddressLine2

STRING

Additional address line.

Suite

STRING

Suite number.

Private Mailbox

STRING

Private mailbox number, when applicable.

Urbanization

STRING

Puerto Rico urbanization, used to distinguish similar addresses in the same postal code.

City

STRING

Required.
City name.

Rancho Santa Margarita

State

STRING

Required.
State name or abbreviation.

CA

Postal Code

STRING

Required.
Five-digit ZIP Code, first five digits of ZIP+4, or full nine-digit ZIP+4.

92688

Country

STRING

Required.
SmartMover USA supports US addresses.

US

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.
If left blank, only the JSON response is returned.

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,
AddressExtras,
AddressKey,
AddressLine1,
AddressLine2,
AddressTypeCode,
BaseMelissaAddressKey,
CarrierRoute,
City,
CityAbbreviation,
CompanyName,
CountryCode,
CountryName,
DeliveryIndicator,
DeliveryPointCheckDigit,
DeliveryPointCode,
MelissaAddressKey,
MoveEffectiveDate,
MoveTypeCode,
PostalCode,
State,
StateName,
Urbanization,
NameFirst,
NameFull,
NameLast,
NameMiddle,
NamePrefix,
NameSuffix,
OriginalAddressLine1,
OriginalAddressLine2,
OriginalCity,
OriginalCityAbbreviation,
OriginalCountryCode,
OriginalPlus4,
OriginalPostalCode,
OriginalPrivateMailbox,
OriginalResults,
OriginalState,
OriginalStateName,
OriginalSuite,
OriginalUrbanization,
AddressDeliveryInstallation,
AddressHouseNumber,
AddressLockBox,
AddressPostDirection,
AddressPreDirection,
AddressPrivateMailboxName,
AddressPrivateMailboxRange,
AddressRouteService,
AddressStreetName,
AddressStreetSuffix,
AddressSuiteName,
AddressSuiteNumber,
StandardizedAddressLine1,
StandardizedAddressLine2,
StandardizedBaseMelissaAddressKey,
StandardizedCarrierRoute,
StandardizedCity,
StandardizedCityAbbreviation,
StandardizedCountryCode,
StandardizedDeliveryIndicator,
StandardizedDeliveryPointCheckDigit,
StandardizedDeliveryPointCode,
StandardizedMelissaAddressKey,
StandardizedPlus4,
StandardizedPostalCode,
StandardizedPrivateMailbox,
StandardizedResults,
StandardizedState,
StandardizedStateName,
StandardizedSuite,
StandardizedUrbanization,
DPVFootNotes,
MoveReturnCode,
Plus4,
PrivateMailbox,
Suite

Jobs Table Name

STRING

The report table name for saving summary report links.

Only valid when Output Table Name is provided. See Save Summary Report Links.

Verify Multiple Addresses#

The Verify Multiple Addresses notebook processes US address records in batches using the SmartMover API and writes results to a Databricks output table.

Requirements#

To use this notebook, you need to prepare an input table in Databricks beforehand referencing our default input fields below. Use the same job_id for all records in the same list, and provide a unique record_id for each row.

Input Fields#

Column Name

Data Type

Description

record_id

STRING

Required.
Unique record identifier, primary key.

company

STRING

Business name; empty string is accepted.

name_full

STRING

Full name of an individual; empty string is accepted.

address_line_1

STRING

Required.
Minimum address location for the contact.

address_line_2

STRING

Additional address line; empty string is accepted.

suite

STRING

Suite number; empty string is accepted.

private_mailbox

STRING

Private mailbox number; empty string is accepted.

urbanization

STRING

Puerto Rico urbanization; empty string is accepted.

city

STRING

Required.
City name.

state

STRING

Required.
State name or abbreviation.

postal_code

STRING

Required.
ZIP Code.

country

STRING

Required.
US country 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,
       CompanyName STRING,
       FullName STRING,
       Address1 STRING,
       Address2 STRING,
       Suite STRING,
       City 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, SMARTMOVER, 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",
          "city": "City",
          "state": "State",
          "postal_code": "PostalCode",
          "country": "Country",
          "company": "CompanyName",
          "name_full": "FullName",
          "address_line_2": "Address2",
          "suite": "Suite",
          "private_mailbox": "",
          "urbanization": "",
        },
        request_parameters={
          "job_id": "YOUR_JOB_ID",
          "paf_id": "",
          "options": "",
          "columns": "",
        },
        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(SMARTMOVER, 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.

job_id
Required. Identifies records belonging to the same list for NCOA reporting. Use the same value for all records in one list.

paf_id
For Broker accounts, identifies the end user. Empty string is accepted.

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

columns
Requested response columns, separated by commas (,). See request columns.

opt_smart_mover_list_name
Identifies the current list. It will be included in reports returned by SmartMover V3 after processing.

job_id: jobid1234,
options: ProcessingType:Standard

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,
InCompany,
InNameFull,
InNameFirst,
InNameMiddle,
InNamePrefix,
InNameSuffix,
InNameLast,
InPlus4,
InAddressLine1,
InAddressLine2,
InSuite,
InCity,
InState,
InPostalCode,
InPrivateMailbox,
InUrbanization,
InCountry,
Results,
AddressExtras,
AddressKey,
AddressLine1,
AddressLine2,
AddressTypeCode,
BaseMelissaAddressKey,
CarrierRoute,
City,
CityAbbreviation,
CompanyName,
CountryCode,
CountryName,
DeliveryIndicator,
DeliveryPointCheckDigit,
DeliveryPointCode,
MelissaAddressKey,
MoveEffectiveDate,
MoveTypeCode,
PostalCode,
State,
StateName,
Urbanization,
Response,
Timestamp,
NameFirst,
NameFull,
NameLast,
NameMiddle,
NamePrefix,
NameSuffix,
OriginalAddressLine1,
OriginalAddressLine2,
OriginalCity,
OriginalCityAbbreviation,
OriginalCountryCode,
OriginalPlus4,
OriginalPostalCode,
OriginalPrivateMailbox,
OriginalResults,
OriginalState,
OriginalStateName,
OriginalSuite,
OriginalUrbanization,
AddressDeliveryInstallation,
AddressHouseNumber,
AddressLockBox,
AddressPostDirection,
AddressPreDirection,
AddressPrivateMailboxName,
AddressPrivateMailboxRange,
AddressRouteService,
AddressStreetName,
AddressStreetSuffix,
AddressSuiteName,
AddressSuiteNumber,
StandardizedAddressLine1,
StandardizedAddressLine2,
StandardizedBaseMelissaAddressKey,
StandardizedCarrierRoute,
StandardizedCity,
StandardizedCityAbbreviation,
StandardizedCountryCode,
StandardizedDeliveryIndicator,
StandardizedDeliveryPointCheckDigit,
StandardizedDeliveryPointCode,
StandardizedMelissaAddressKey,
StandardizedPlus4,
StandardizedPostalCode,
StandardizedPrivateMailbox,
StandardizedResults,
StandardizedState,
StandardizedStateName,
StandardizedSuite,
StandardizedUrbanization,
DPVFootNotes,
MoveReturnCode,
Plus4,
PrivateMailbox,
Suite

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

jobs_table

STRING

Name of the jobs table.

Automatically save summary report links to a report table. A new table will be created if it doesn’t exist. See Save Summary Report Links for more information.

catalog.schema.jobs_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

InAddressLine1

STRING

InCity

STRING

InState

STRING

InPostalCode

STRING

InCompany

STRING

InNameFull

STRING

InNameFirst

STRING

InNameMiddle

STRING

InNamePrefix

STRING

InNameSuffix

STRING

InNameLast

STRING

InAddressLine2

STRING

InSuite

STRING

InPrivateMailbox

STRING

InUrbanization

STRING

InPlus4

STRING

InCountry

STRING

MelissaAddressKey

STRING

BaseMelissaAddressKey

STRING

Results

STRING

AddressLine1

STRING

AddressTypeCode

STRING

CarrierRoute

STRING

City

STRING

CityAbbreviation

STRING

CompanyName

STRING

DeliveryIndicator

STRING

MoveEffectiveDate

STRING

MoveTypeCode

STRING

PostalCode

STRING

State

STRING

Urbanization

STRING

AddressExtras

STRING

Timestamp

TIMESTAMP

Result Codes#

For the full list of result codes returned by SmartMover USA Notebook: Databricks, please visit Result Codes - SmartMover USA: Databricks.