Table Row Filter with a criteria on CURRENT_USER() belonging to a Unity Catalog group
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2024 05:36 AM
Hello
I defined a Row Filter to exclude some rows for a given user 'user@mail.com' in SQL.
Instead of providing a list of users to exclude, I would like to define my criteria on Unity Catalog groups instead of users.
Here is my current filter:
-- apply filter only for user@mail.com, otherwise bypass filter
CREATE FUNCTION rd.my_schema.my_filter(filter_column INTEGER) RETURNS BOOLEAN
RETURN IF(CURRENT_USER() = 'user@mail.com', filter_column IN (15), true);
And I apply this Row Filter to 2 of my tables like so:
ALTER TABLE rd.my_schema.my_table_1 SET ROW FILTER rd.my_schema.my_filter ON (id_col);
ALTER TABLE rd.my_schema.my_table_2 SET ROW FILTER rd.my_schema.my_filter ON (id_col);
Could someone help me adapt this filter so that it only applies if the user executing the query is member of a given group (let's say it is named 'restricted_users_group') ?
Thanks
Thanks
0 REPLIES 0

