cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

Insufficient Permission when writing to AWS Redshift

eric-cordeiro
New Contributor II

I'm trying to write a table in AWS Redshift using the following code:

try:
    (df_source.write
        .format("redshift")
        .option("dbtable", f"{redshift_schema}.{table_name}")
        .option("tempdir", tempdir)
        .option("url", url)
        .option("user", user)
        .option("password", password)
        .option("forward_spark_s3_credentials", True)
        .option("tempformat", "CSV GZIP")
        .mode("overwrite")
        .save())
except Exception as e:
    raise Exception(f'ERRO: {str(e)}')

However I'm getting the following error:

"Exception: ERRO: An error occurred while calling o450.save. : org.apache.spark.SparkSecurityException: [INSUFFICIENT_PERMISSIONS] Insufficient privileges: User does not have permission SELECT on any file."

I've seen a solution to have an admin run a sql command like 
GRANT SELECT ON ANY FILE TO `user1`
But it's not working and I don't think I'd like to give this grant to every user/group. So, why is this happening and how can I solve it in a more proper manner? I also have unity catalog enabled. Thank you!
1 REPLY 1

Kaniz
Community Manager
Community Manager

Hi @eric-cordeiro

 

1. Ensure that the user has the USAGE privilege on the schema where the table resides. You can grant this privilege using the following SQL command:

GRANT USAGE ON SCHEMA <schema_name> TO <schema_user>;

 

2. Since you mentioned having Unity Catalog enabled, ensure that the catalog is correctly configured and integrated with your Redshift cluster. Verify that the user has the necessary permissions within Unity Catalog as well.


 

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.