Date UDFs

Date UDFs in Trino

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

Caution: There are inconsistencies observed when Trino is used to fetch and store date values from HDFS, where data was stored using Hive. It is recommended to verify if the correct date and datetime values are retrieved when the data is fetched from or stored in HDFS without using the Trino UDFs. If the data consistency is maintained, only then proceed to the Trino Date or DateTime UDFs.

ptyProtectDate()

This UDF protects the Date value.

Signature:

ptyProtectDate(date input, varchar dataElement)

Parameters:

NameTypeDescription
inputDateSpecifies the data to protect.
dataElementVarCharSpecifies the name of the data element to protect the data.

Returns:
This UDF returns the protected Date value.

Example:

select PtyProtectDate(cast('2018-10-10' as date), 'Date_DE');

Supported Protection Methods:

Function NameTokenizationEncryptionFPENo EncryptionMaskingMonitoring
ptyProtectDate()DateNoNoYesNoYes

ptyUnprotectDate()

This UDF unprotects the protected Date value.

Signature:

ptyUnprotectDate(date input, varchar dataElement)

Parameters:

NameTypeDescription
inputDateSpecifies the protected data to unprotect.
dataElementVarCharSpecifies the name of the data element to unprotect the data.

Returns:
This UDF returns the unprotected Date value.

Example:

select ptyUnprotectDate(PtyProtectDate(cast('2018-10-10' as date), 'Date_DE'), 'Date_DE');

Supported Protection Methods:

Function NameTokenizationEncryptionFPENo EncryptionMaskingMonitoring
ptyUnprotectDate()DateNoNoYesNoYes

ptyReprotect() - Date

This UDF reprotects the Date format protected data, which was earlier protected using the ptyProtectDate UDF, with a different data element.

Signature:

ptyReprotect(date input, varchar oldDataElement, varchar newDataElement)

Parameters:

NameTypeDescription
inputDateSpecifies the Date 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.

Warning: Ensure to use the data element with the No Encryption method only. Using any other data element might cause data corruption.

Returns:
This UDF returns the protected Date value.

Example:

select PtyReprotect(cast('2018-10-10' as date), 'Date_DE', 'new_Date_DE');

Supported Protection Methods:

Function NameTokenizationEncryptionFPENo EncryptionMaskingMonitoring
ptyReprotect()DateNoNoYesNoYes

Last modified : December 18, 2025