Skip to content

Privacera Encryption - Protect, Unprotect and Mask Data with Databricks Cluster

This guide explains how to use Privacera's User-Defined Functions (UDFs) to perform data protection, unprotection , and masking directly within your Databricks SQL queries.

Prerequisites

Before you begin, ensure the following prerequisites are met:

  • A Databricks cluster is up and running.
  • Ensure your Databricks environment supports Scala.
  • Privacera Encryption Gateway (PEG) must be enabled and properly configured. For details, see the PEG setup documentation
  • Generate the necessary system schemes within Privacera.
  • The target table exists and contains valid data for protect, unprotect, or mask operations.
  • A masking scheme named TEXT_MASK is created with the format type set to Text and an appropriate masking technique selected.

Protect Data

Run the following command to protect data in a column.

SQL
select privacera.protect(email,'SYSTEM_EMAIL') from <DATABASE>.<TABLE> as enc_email;

Unprotect Data

Run the following command to unprotect data in a column.

SQL
select privacera.unprotect(email,'SYSTEM_EMAIL') from <DATABASE>.<TABLE> as dec_email;

Mask Data

Run the following command to mask data in a column.

SQL
select privacera.mask(email,'TEXT_MASK') from <DATABASE>.<TABLE> as mask_email;

Comments