In this section, you find the details of Apache Ranger policy to set a custom expression
to transform the value of name_first column.
Data before transformation
The following example shows the data before transformation:
+-----+-------------+------------+---------------+----------------+--------------+
| id | name_first | name_last | addr_country | date_of_birth | phone_num |
+-----+-------------+------------+---------------+----------------+--------------+
| 1 | Mackenzy | Smith | US | 1993-12-18 | 123-456-7890 |
| 2 | Sherlyn | Miller | US | 1975-03-22 | 234-567-8901 |
| 3 | Khiana | Wilson | US | 1989-08-14 | 345-678-9012 |
| 4 | Jack | Thompson | US | 1962-10-28 | 456-789-0123 |
| 5 | Felix | Lee | CA | 1982-04-17 | 321-654-0987 |
| 6 | Adam | Brown | CA | 1995-09-07 | 432-765-1098 |
| 7 | Lucas | Jones | CA | 1999-02-06 | 543-876-2109 |
+-----+-------------+------------+---------------+----------------+--------------+
Policy details
Add a policy with the following details to specify the expression, initcap(reverse({col})),
to transform name_first column values. Ensure that the data type of the expression is same as
the data type of the column. Token ‘{col}’ in the expression will be replaced by Apache Ranger
policy engine by the name of the column on which masking is being applied.
Query Results
The query result shows transformed value name_first column, as shown in the following
example: