Pig UDFs

ptyGetVersion()

The function returns the current version of the protector.

Signature:

ptyGetVersion()

Parameters:

  • None

Result:

  • The function returns the version number in a chararray.

Example:

REGISTER </path/to/bdp/lib/>/peppig-<jar_version>.jar;
// register pep pig version
DEFINE ptyGetVersion com.protegrity.pig.udf.ptyGetVersion;
//define UDF
employees = LOAD employee.csv using PigStorage(,) AS (eid:chararray,name:chararray, ssn:chararray);
// load employee.csv from HDFS path
version = FOREACH employees GENERATE ptyGetVersion();
DUMP version;

ptyGetVersionExtended()

The function returns the extended version information of the protector.

Signature:

ptyGetVersionExtended()

Parameters:

  • None

Result:

  • The function returns a chararray in the following format:
    BDP: <1>; JcoreLite: <2>; CORE: <3>;
    
    where,
      1. is the current version of the Protector
      1. is the Jcorelite library version
      1. is the Core library version

Example:

REGISTER </path/to/bdp/lib/>/peppig-<jar_version>.jar;
// register pep pig version
DEFINE ptyGetVersionExtended com.protegrity.pig.udf.ptyGetVersionExtended;
//define UDF
employees = LOAD employee.csv using PigStorage(,) AS (eid:chararray,name:chararray, ssn:chararray);
// load employee.csv from HDFS path
version = FOREACH employees GENERATE ptyGetVersionExtended();
DUMP version;

ptyWhoAmI()

The function returns the current logged in user name.

ptyWhoAmI()

Parameters:
None

Result:

  • The function returns the User name in a chararray.

Example:

REGISTER </path/to/bdp/lib/>/peppig-<jar_version>.jar;
DEFINE ptyWhoAmI com.protegrity.pig.udf.ptyWhoAmI;
employees = LOAD ‘employee.csv’ using PigStorage(‘,’) AS (eid:chararray, name:chararray, ssn:chararray);
username = FOREACH employees GENERATE ptyWhoAmI();
DUMP username;

ptyProtectInt()

The function returns the protected value for integer data.

ptyProtectInt (int data, chararray dataElement)

Parameters:

  • int data : Specifies the data to protect.
  • chararray dataElement: Specifies the name of the data element to use for data protection.

Result:

  • The function returns the protected value for the given numeric data.

Example:

REGISTER </path/to/bdp/lib/>/peppig-<jar_version>.jar;
DEFINE ptyProtectInt com.protegrity.pig.udf.ptyProtectInt;
employees = LOAD ‘employee.csv’ using PigStorage(‘,’) AS (eid:int, name:chararray, ssn:chararray);
data_p = FOREACH employees GENERATE ptyProtectInt(eid, ‘token_integer’);
DUMP data_p;

Supported Protection Methods:

Function NameTokenizationEncryptionFPENo EncryptionMaskingMonitoring
ptyProtectInt()Integer 4 BytesNoNoYesNoYes

ptyUnprotectInt()

The function returns the unprotected value for protected data in the integer format.

ptyUnprotectInt (int data, chararray dataElement)

Parameters:

  • int data : Is the protected data.
  • chararray dataElement: Specifies the name of the data element to unprotect the data.

Result:
The function returns the unprotected value for the specified protected integer data.

Example:

REGISTER </path/to/bdp/lib/>/peppig-<jar_version>.jar;
DEFINE ptyProtectInt com.protegrity.pig.udf.ptyProtectInt;
DEFINE ptyUnprotectInt com.protegrity.pig.udf.ptyUnProtectInt;
employees = LOAD ‘employee.csv’ using PigStorage(‘,’) AS (eid:int, name:chararray, ssn:chararray);
data_p = FOREACH employees GENERATE ptyProtectInt(eid, ‘token_integer’);
data_u = FOREACH data_p GENERATE ptyUnprotectInt(eid, ‘token_integer’);
DUMP data_u;

Supported Protection Methods:

Function NameTokenizationEncryptionFPENo EncryptionMaskingMonitoring
ptyUnprotectInt()Integer 4 BytesNoNoYesNoYes

ptyProtectStr()

The function protects the string value.

Note: For Date and Datetime type of data elements, the protect API returns an invalid input data error if the input value falls between the non-existent date range from 05-OCT-1582 to 14-OCT-1582 of the Gregorian Calendar.
For more information about the tokenization and de-tokenization of the cutover dates of the Proleptic Gregorian Calendar, refer Date and Datetime tokenization.

ptyProtectStr(chararray input, chararray dataElement)

Parameters:

  • chararray data: Specifies the string value to protect.
  • chararray dataElement: Specifies the name of the data element to protect the string value.

Result:

  • The function returns the protected string value in a chararray.

Example:

REGISTER </path/to/bdp/lib/>/peppig-<jar_version>.jar;
DEFINE ptyProtectStr com.protegrity.pig.udf.ptyProtectStr;
employees = LOAD ‘employee.csv’ using PigStorage(‘,’) AS (eid:chararray, name:chararray, ssn:chararray);
data_p = FOREACH employees GENERATE ptyProtectIntStr(name, ‘token_alphanumeric’);
DUMP data_p

Supported Protection Methods:

Function NameTokenizationEncryptionFPENo EncryptionMaskingMonitoring
ptyProtectStr()
  • Numeric (0-9)
  • Credit Card
  • Alpha (A-Z)
  • Upper-case Alpha (A-Z)
  • Alpha-Numeric (0-9, a-z, A-Z)
  • Upper Alpha-Numeric (0-9, A-Z)
  • Lower ASCII
  • Date (YYYY-MM-DD, DD/MM/YYYY, MM.DD.YYYY)
  • Datetime (YYYY-MM-DD HH:MM:SS)
  • Decimal
  • Email
NoYesYesYesYes

ptyUnprotectStr()

The function unprotects the protected string value.

Note: For Date and Datetime type of data elements, the protect API returns an invalid input data error if the input value falls between the non-existent date range from 05-OCT-1582 to 14-OCT-1582 of the Gregorian Calendar.
For more information about the tokenization and de-tokenization of the cutover dates of the Proleptic Gregorian Calendar, refer Date and Datetime tokenization.

ptyUnprotectStr (chararray input, chararray dataElement)

Parameters:

  • chararray input: Specifies the protected string value.
  • chararray dataElement: Specifies the name of the data element to unprotect the string value.

Result:

  • The function returns the unprotected value in a chararray.

Example:

REGISTER </path/to/bdp/lib/>/peppig-<jar_version>.jar;
DEFINE ptyProtectInt com.protegrity.pig.udf.ptyProtectStr;
DEFINE ptyUnprotectInt com.protegrity.pig.udf.ptyUnProtectStr;
employees = LOAD ‘employee.csv’ using PigStorage(‘,’) AS (eid:chararray, name:chararray, ssn:chararray);
data_p = FOREACH employees
GENERATE ptyProtectStr(name, ‘token_alphanumeric’) as name:chararray
DUMP data_p;
data_u = FOREACH data_p GENERATE ptyUnprotectStr(ssn, ‘Token_alphanumeric’);
DUMP data_u;

Supported Protection Methods:

Function NameTokenizationEncryptionFPENo EncryptionMaskingMonitoring
ptyUnprotectStr()
  • Numeric (0-9)
  • Credit Card
  • Alpha (A-Z)
  • Upper-case Alpha (A-Z)
  • Alpha-Numeric (0-9, a-z, A-Z)
  • Upper Alpha-Numeric (0-9, A-Z)
  • Lower ASCII
  • Date (YYYY-MM-DD, DD/MM/YYYY, MM.DD.YYYY)
  • Datetime (YYYY-MM-DD HH:MM:SS)
  • Decimal
  • Email
NoYesYesYesYes

Last modified : December 18, 2025