cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Warehousing & Analytics
Engage in discussions on data warehousing, analytics, and BI solutions within the Databricks Community. Share insights, tips, and best practices for leveraging data for informed decision-making.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

databricks dashboards - how do share the dashboard to user with Limit the data access

boopa45
New Contributor

how do share the dashboard to user with Limit the data access without create a new dashboard with filler in source qry?

is there any other way?

example,

I have a dashboard it contains 3 location data example

India 

Canada

USA

 

I need to give limited acces to below users

India - User1

Canada - User2

USA - User3

 

if i give view access to User1 then user1 can view/work with India data only. other country data user2 should not have access. 

 

pls let me know.

 

5 REPLIES 5

Coffee77
Contributor III

Take a look at this docuumentation https://docs.databricks.com/aws/en/data-governance/unity-catalog/filters-and-masks/ Try to use "Row Filters" and/or "Dynamic Views"


Lifelong Learner Cloud & Data Solution Architect | https://www.youtube.com/@CafeConData

Hi @Coffee77 ,

any sample code or anything for ref? becuase i am new to databricks dashboard. 

Try to use "Row Filters" and/or "Dynamic Views" - we can shere on dashboard and based on the user it will be lmit the access right?

pls provide any ref dashboard or code or anything it would be grateful.

Take a look here on how to create "SQL Functions to manually apply as Row Filters" as it seems to be the most simple approach : https://docs.databricks.com/gcp/en/data-governance/unity-catalog/filters-and-masks/manually-apply#ro... https://docs.databricks.com/aws/en/data-governance/unity-catalog/abac/udf-best-practices 

After creating those SQL Functions, you should apply to tables or materialized views, in a way similar to this: https://learn.microsoft.com/en-us/azure/databricks/data-governance/unity-catalog/filters-and-masks/m... 

Then, select those tables or views from the dashboards data sources. The SQL function acting as "Row Filter" will filter rows automatically as per your desired parameters.

Partial sample here BUT use table in dashboard instead of DLT: https://medium.com/@aryan.sinanan/databricks-apply-row-filters-sql-or-py-dlt-4f369681e1fe 

 


Lifelong Learner Cloud & Data Solution Architect | https://www.youtube.com/@CafeConData

boopa45
New Contributor

this is source query level right? what if user has only view access?

twole
Databricks Employee
Databricks Employee

You can use a code sample like this

--example syntax
CREATE FUNCTION us_filter(region STRING)
RETURN IF(IS_ACCOUNT_GROUP_MEMBER('admin'), true, region='US');

-- specific to your example
CREATE FUNCTION region_filter(region STRING)
RETURN
  CASE
    -- Users in USA-only group see only USA rows
    WHEN IS_ACCOUNT_GROUP_MEMBER('usa_users') THEN region = 'usa'
    -- Users in India-only group see only India rows
    WHEN IS_ACCOUNT_GROUP_MEMBER('india_users') THEN region = 'india'
    -- Everyone else sees nothing
    ELSE false
  END;

Then apply this function as a row filter on your table

ALTER TABLE sample_regions_table SET ROW FILTER region_filter_2 ON (region); --assuming your region column is called 'region'

Once the viewers query the dashboard, the filter will be applied.

You need to apply the function to the source table for row-level security to work. Is there a reason why you don't want to do this?