Skip to main content

Privacera Platform master publication

Create and run Databricks UDFs for encryption
:

You can create Privacera Encryption user-defined functions (UDFs) by running SQL queries in your Databricks cluster.

Create Privacera protect UDF

To create a Privacera protect user-defined function (UDF), run the following SQL query in your Databricks cluster:

create database if not exists privacera;
drop function if exists privacera.protect;
CREATE FUNCTION privacera.protect AS 'com.privacera.crypto.PrivaceraEncryptUDF';
Create Privacera unprotect UDF

To create a Privacera unprotect user-defined function (UDF), run the following SQL query in your Databricks cluster:

create database if not exists privacera;
drop function if exists privacera.unprotect;
CREATE FUNCTION privacera.unprotect AS 'com.privacera.crypto.PrivaceraDecryptUDF';
Run sample queries in Databricks to verify

You can run queries to verify that the definitions of the UDFs in Databricks actually do work. These queries do the following:

  1. Run the protect UDF to encrypt a database column shown as a variable <colname> . Substitute your own column name for this variable.

  2. Run the unprotect UDF to decrypt that same database column.

Sample query to run encryption:

select privacera.protect($<colname>,'$<SCHEME_NAME>') from $<db_name>.$<table_name> limit10;

Sample query to run encryption and decryption in a single query to verify the setup:

select privacera.unprotect(privacera.protect($<colname>,'$<SCHEME_NAME>'),'$<SCHEME_NAME>') from $<db_name>.$<table_name> limit10;