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: 

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!

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