A data engineer is troubleshooting an issue where an Amazon Redshift query returns an error: 'ERROR: permission denied for relation table_name'. The user has been granted SELECT on the table. What is the most likely cause?
Trap 1: The user's session has timed out.
A timed-out session produces a connection or authentication failure, not a relation-level permission error; the query would not reach permission checking. It is tempting because session expiry is a common Redshift annoyance, but it applies when reconnecting is needed, not when SELECT has been granted yet denied.
Trap 2: The user does not have CONNECT permission on the database.
Without CONNECT on the database the user cannot log in or run any query at all, so the failure would occur before reaching the table. It is tempting because CONNECT is a prerequisite permission, but the stem shows the query executing and failing specifically on the relation.
Trap 3: The table is in a different schema than expected.
If the table sits in another schema, the unqualified name resolves elsewhere or fails to resolve, and SELECT granted on the intended table does not apply. It is tempting because search_path issues are common, but the error names the relation, indicating the table was found and permission was checked.
- A
The user's session has timed out.
Why it fails: A timed-out session produces a connection or authentication failure, not a relation-level permission error; the query would not reach permission checking. It is tempting because session expiry is a common Redshift annoyance, but it applies when reconnecting is needed, not when SELECT has been granted yet denied.
- B
The user does not have CONNECT permission on the database.
Why it fails: Without CONNECT on the database the user cannot log in or run any query at all, so the failure would occur before reaching the table. It is tempting because CONNECT is a prerequisite permission, but the stem shows the query executing and failing specifically on the relation.
- C
The table is in a different schema than expected.
Why it fails: If the table sits in another schema, the unqualified name resolves elsewhere or fails to resolve, and SELECT granted on the intended table does not apply. It is tempting because search_path issues are common, but the error names the relation, indicating the table was found and permission was checked.
- D
The user does not have USAGE permission on the schema.
Redshift requires USAGE on the containing schema before SELECT on a table is honoured. Without schema USAGE, the query fails with permission denied even though SELECT was granted, making the missing schema-level privilege the most likely cause.