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#
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. |
|
PAFID |
STRING |
Required; empty string is accepted. |
|
JobID |
STRING |
Required. |
jobid1234 |
Options |
STRING |
[OptionName:Parameter], separated by commas (,). |
ProcessingType:Standard |
Columns |
STRING |
Requested response columns, separated by commas (,). |
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. |
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. |
Rancho Santa Margarita |
State |
STRING |
Required. |
CA |
Postal Code |
STRING |
Required. |
92688 |
Country |
STRING |
Required. |
US |
Output Table Name |
STRING |
The output table name. |
|
Output Table Fields |
STRING |
Case-sensitive. |
RecordID, |
Jobs Table Name |
STRING |
The report table name for saving 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. |
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. |
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. |
state |
STRING |
Required. |
postal_code |
STRING |
Required. |
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, 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, 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, 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. |
|
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: jobid1234, |
|
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 |
jobs_table |
STRING |
Name of the jobs table. |
catalog.schema.jobs_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 |
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 |
Save Summary Report Links#
You can save the summary report links to an output table by providing a name for the jobs table.
A new jobs table will be created with the default schemas as below if it doesn’t exist.
Column Name |
Data Type |
|---|---|
JobID |
STRING |
PAFId |
STRING |
ListName |
STRING |
RunId |
STRING |
CASSReportLink |
STRING |
NCOAReportLink |
STRING |
Timestamp |
TIMESTAMP |
Query the jobs table to get the summary report links.
SELECT *
FROM <jobs_table_name>
WHERE jobID = '<your_job_id>';
Result Codes#
For the full list of result codes returned by SmartMover USA Notebook: Databricks, please visit Result Codes - SmartMover USA: Databricks.