Friday 12 June 2020

Query to get resource class of user in Azure Synapse

I struggled a bit find to find which user is assigned to which resource class in Azure Synapse. After short effort I prepare this query to get the details. Thought it is worth sharing.

SELECT u.[name] as [User Name], p.[name] as [Resource Class] FROM sys.database_principals AS p
INNER JOIN sys.database_role_members AS r on p.principal_id = r.role_principal_id
INNER JOIN sys.sysusers AS u ON u.uid = r.member_principal_id
WHERE p.[name] like '%rc%' and u.[name] = 'user'

Happy Coding!!

Friday 5 June 2020

AssertionError: col should be Column (Azure Databricks)

You get the error "AssertionError: col should be Column" when you try to add column to DataFrame.

df_col  = df_col.withColumn("UniqueID", hash(str(col)))

To solve this just import following and you should get rid of the error. Still did not found the cause but it worked. Will update as soon as cause is found.

from pyspark.sql.functions import *

Happy Coding!