cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Table Row Filter with a criteria on CURRENT_USER() belonging to a Unity Catalog group

Antoine_B
New Contributor III

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 INTEGERRETURNS 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 
1 REPLY 1

Kaniz_Fatma
Community Manager
Community Manager

Hi @Antoine_B, To update your SQL Row Filter to apply based on group membership rather than a specific user, you can use Unity Catalogโ€™s group functionality.

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group