Why do I get permission denied when querying a view in AWS Redshift but not when running the query used to make the view?
When I try to run:
SELECT * FROM "dev"."public"."stg_kfdb_answers_flattened";
I get the error:
ERROR: permission denied for relation answers [ErrorId: 1-63c08c6b-616566234b35efdf64d5f06c]
But stg_kfdb_answers_flattened is a view, with the definition being:
CREATE
OR
REPLACE
VIEW "public".stg_kfdb_answers_flattened AS
SELECT
json_extract_path_text(answers.document ::text, '_id' ::text) AS id,
<etc.>,
FROM
<source_schema>.<source_table>;
When I run the query by itself, it works just fine. But when I create the view, as you see above, it gives me a permission denied error.
I have already tried giving myself permissions with statements like from this previous question.
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public to jerry;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public to jerry;
GRANT ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA public to jerry;
But none of these have seemed to help. What am I doing wrong?