Notebook Personator Consumer: Databricks Python Package#
Introduction#
The Melissa Databricks Python Package provides access to the Personator Consumer API from Databricks notebooks. It reads consumer contact records from a Databricks table and writes check and enrichment results to an output table.
Click here to learn more about the Personator Consumer Cloud API.
Prerequisites#
Access to a Databricks workspace.
An input table containing consumer contact data. Provide at least one supported input combination described in Personator Consumer minimum input combinations.
Permission to read the input table and create or write to the output table.
The Melissa Databricks Python Package installed in the Databricks environment. See installation.
A Melissa License Key with Credits. See License Key Information.
Usage#
Imports#
from melissadatacloudapi_databricks import Config, PERSONATOR_CONSUMER, run
Components#
Name |
Description |
|---|---|
|
Holds the settings for a run: license key, input and output tables, field mapping, request parameters, output columns, logging, and duplicate checking. |
|
The product definition for Personator Consumer. It tells |
|
Processes every record in the input table and writes the results to the output table. |
Configuration#
Map the package parameters to input table columns. At least one supported input combination is required. Use an empty string for optional values that are not in the input table.
config = Config(
license_key=LICENSE_KEY,
input_table="<catalog>.<schema>.<input_table>",
output_table="<catalog>.<schema>.<output_table>",
parameter_mapping={
"record_id": "",
"address_line_1": "",
"city": "City",
"state": "State",
"postal_code": "",
"last_line": "",
"email_address": "",
"phone_number": "",
"full_name": "",
"ip_address": "",
"free_form": "",
"melissa_address_key": "",
"melissa_identity_key": "",
"first_name": "",
"last_name": "",
"company_name": "",
"address_line_2": "",
"country": "",
"birth_day": "",
"birth_month": "",
"birth_year": "",
"age_approximate": "",
"age_greater_than": "",
"age_less_than": "",
},
request_parameters={
"actions": "Check",
"columns": "",
"options": "",
},
output_columns="",
log_to_table=False,
log_table="<catalog>.<schema>.<log_table>",
duplicate_check=False,
)
Input Parameters#
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. |
Check,Move |
|
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 |
Example#
config = Config(
license_key=LICENSE_KEY,
input_table="main.default.contacts",
output_table="main.default.contacts_verified",
parameter_mapping={
"record_id": "RecordID",
"full_name": "FullName",
"address_line_1": "AddressLine1",
"city": "City",
"state": "State",
"postal_code": "PostalCode",
"email_address": "Email",
},
request_parameters={
"actions": "Check",
"columns": "",
"options": "UsePreferredCity:on",
},
output_columns="RecordID,Results,NameFull,AddressLine1,City,State,PostalCode,EmailAddress",
log_to_table=True,
log_table="main.default.contacts_logs",
duplicate_check=False,
)
Execution#
run(PERSONATOR_CONSUMER, config, spark=spark, dbutils=dbutils)