VarChar UDFs

VarChar UDFs in Trino

This section provides a list of Varchar UDFs for the protect, unprotect, and reprotect operations.

Consider a Trino session where you impersonate a user using the –user parameter as shown in the following example.

./TrinoCLI --server localhost:8080 --catalog hive --schema default --user=<sample_user>

If you execute any UDF after impersonating a user, then the query execution happens for the impersonated user <sample_user>. This is a limitation of Trino.

ptyProtectStr()

This UDF protects the varchar values.

Signature:

ptyProtectStr(varchar input, varchar dataElement)

Parameters:

NameTypeDescription
inputVarCharSpecifies the varchar value to protect.
dataElementVarCharSpecifies the name of the data element to protect the varchar value.

Returns:
This UDF returns the protected varchar value.

Example:

select ptyProtectStr('ProtegrityProt','Varchar_DE');

Supported Protection Methods:

Function NameTokenizationEncryptionFPENo EncryptionMaskingMonitoring
ptyProtectStr()
  • Numeric (0-9)
  • Credit Card
  • Alpha
  • Upper Case Alpha
  • Alpha Numeric
  • Upper Alpha Numeric
  • Lower ASCII
  • Datetime (YYYY-MM-DD HH:MM:SS)
  • Date (YYYY-MM-DD, DD/MM/YYYY, MM.DD.YYYY)
  • Decimal
  • Email
  • Unicode (Legacy)
  • Unicode (Base64 - Encoded Byte's Charset should match Dataelement's Encoding Type)
  • Unicode (Gen2)
NoYesYesYesYes

ptyUnprotectStr()

This UDF unprotects the existing protected varchar value.

Signature:

ptyUnprotectStr(varchar input, varchar dataElement)

Parameters:

NameTypeDescription
inputVarCharSpecifies the protected varchar value to unprotect.
dataElementVarCharSpecifies the name of the data element to unprotect the varchar value.

Returns:
This UDF returns the unprotected varchar value.

Example:

select ptyUnProtectStr(PtyProtectStr('ProtegrityProt','Varchar_DE'),'Varchar_DE');

Supported Protection Methods:

Function NameTokenizationEncryptionFPENo EncryptionMaskingMonitoring
ptyUnprotectStr()
  • Numeric (0-9)
  • Credit Card
  • Alpha
  • Upper Case Alpha
  • Alpha Numeric
  • Upper Alpha Numeric
  • Lower ASCII
  • Datetime (YYYY-MM-DD HH:MM:SS)
  • Date (YYYY-MM-DD, DD/MM/YYYY, MM.DD.YYYY)
  • Decimal
  • Email
  • Unicode (Legacy)
  • Unicode (Base64 - Encoded Byte's Charset should match Dataelement's Encoding Type)
  • Unicode (Gen2)
NoYesYesYesYes

ptyReprotect() - Str

This UDF reprotects the varchar protected data, which was earlier protected using the ptyProtectStr UDF, with a different data element.

Signature:

ptyReprotect(varchar input, varchar oldDataElement, varchar newDataElement)

Parameters:

NameTypeDescription
inputVarCharSpecifies the varchar value to reprotect.
oldDataElementVarCharSpecifies the name of the data element that was initially used to protect the data.
newDataElementVarCharSpecifies the name of the new data element to reprotect the data.

Returns:
This UDF returns the protected varchar value.

Example:

select ptyReprotect(PtyProtectStr('ProtegrityProt','Varchar_DE'),'Varchar_DE','new_Varchar_DE');

Supported Protection Methods:

Function NameTokenizationEncryptionFPENo EncryptionMaskingMonitoring
ptyReprotect()
  • Numeric (0-9)
  • Credit Card
  • Alpha
  • Upper Case Alpha
  • Alpha Numeric
  • Upper Alpha Numeric
  • Lower ASCII
  • Datetime (YYYY-MM-DD HH:MM:SS)
  • Date (YYYY-MM-DD, DD/MM/YYYY, MM.DD.YYYY)
  • Decimal
  • Email
  • Unicode (Legacy)
  • Unicode (Base64 - Encoded Byte's Charset should match Dataelement's Encoding Type)
  • Unicode (Gen2)
NoYesYesYesYes

Last modified : December 18, 2025