cancel
Showing results for 
Search instead for 
Did you mean: 
Warehousing & Analytics
cancel
Showing results for 
Search instead for 
Did you mean: 

Group-user link via SQL

rcmarcelo
New Contributor III

I've been trying to check, via databricks SQL, which groups a user belongs to.

When I run SHOW GROUPS or SHOW USERS, everything is returned correctly.

However, when a try to run:

SHOW GROUPS WITH USER `user@domain.com`

Nothing is returned, but the user belongs to one of the existing groups.

What is the right way to execute this query and get the expected results?

1 ACCEPTED SOLUTION

Accepted Solutions

rcmarcelo
New Contributor III

Hey! The actual solution was to run SHOW GROUPS WITH USER as an administrator. This wasn't expected, since SHOW USERS and SHOW GROUPS doesn't require administrator privileges and there's nothing mentioned in the docs. Thanks!

View solution in original post

3 REPLIES 3

Anonymous
Not applicable

@Marcelo Castro​ :

To show the groups that a user belongs to in Databricks using SQL, you can use the following query:

SELECT groupname FROM databricks_groups WHERE userid IN (SELECT userid FROM databricks_users WHERE username = 'user@domain.com')

This query uses the databricks_users and databricks_groups tables to get the userid associated with the username and then returns the group names associated with that userid. You can replace 'user@domain.com' with the username of the user you want to check. This should return the group names that the user belongs to.

Note that you will need the appropriate privileges to query the databricks_users and databricks_groups

tables.

Anonymous
Not applicable

Hi @Marcelo Castro​ 

Hope all is well! Just wanted to check in if you were able to resolve your issue and would you be happy to share the solution or mark an answer as best? Else please let us know if you need more help. 

We'd love to hear from you.

Thanks!

rcmarcelo
New Contributor III

Hey! The actual solution was to run SHOW GROUPS WITH USER as an administrator. This wasn't expected, since SHOW USERS and SHOW GROUPS doesn't require administrator privileges and there's nothing mentioned in the docs. Thanks!

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.