Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

Masking timestamps

avatar
Rising Star

Is there a way of masking timestamps using the masking policies in Ranger? Perhaps through a custom UDF referenced in the policy?

The masking type of "Date: show only year" only works for dates, not timestamps.

Looking at GitHub (as the Ranger documentation isn't complete) timestamps cannot be masked, only nullified - https://github.com/myui/hive-udf-backports/tree/master/src/main/java/org/apache/hadoop/hive/ql/udf/g...

mask(value, upperChar, lowerChar, digitChar, otherChar, numberChar, dayValue, monthValue, yearValue)

Supported types: TINYINT, SMALLINT, INT, BIGINT, STRING, VARCHAR, CHAR, DATE

Reason: some systems store dates as timestamps, so date of birth (PII) could be stored as a timestamp and I need to mask it.

1 ACCEPTED SOLUTION

avatar
Rising Star

It's not elegant, but this custom masking seems to work.

cast(mask(cast(to_date({col}) as date), 'x', 'x', 'x', -1, '1', 1, 0, -1) as timestamp)

View solution in original post

1 REPLY 1

avatar
Rising Star

It's not elegant, but this custom masking seems to work.

cast(mask(cast(to_date({col}) as date), 'x', 'x', 'x', -1, '1', 1, 0, -1) as timestamp)