The data-masking function

Since Hive v2.1.0, the data-mask function has been available in SQL as built-in UDF. Masking data is quite often requested for user-sensitive data such as credit card numbers, bank account numbers, and passwords. Different from the hash function, the mask function in SQL can specify masking on partial data, which makes it more flexible when you want to keep part of the data unmasked for better understanding. The following are examples of using various mask functions in HQL:

> SELECT -- big letter to U, small letter to l, number to #> mask("Card-0123-4567-8910", "U", "l", "#") as m0, -- mask first n (4) values where X|x for big/small letter, n for number> mask_first_n("Card-0123-4567-8910", 4) as m1, -- mask last ...

Get Apache Hive Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.