Due to the append-only nature of Redshift, we often need to consolidate tables to remove duplicate records and surface the most recent version of a record. To prepare for this process, the base table is renamed and a copy of it is made. A script will execute to scan through the insert table and move the most recent unique records into the new base table. However, if the table has been running for awhile prior to this process beginning, there may be grants on the table that are not copied over when the clone is created.
We often do not have the original table DDL, and though we are able to get it via https://github.com/awslabs/amazon-redshift-utils/blob/master/src/AdminViews/v_generate_tbl_ddl.sql this will not generate the table definition with any grants.
Is there a way to copy a table with grants in-place, or generate a script to create the grants based on the old table?
Have tried using https://github.com/awslabs/amazon-redshift-utils/blob/master/src/AdminViews/v_generate_tbl_ddl.sql but this does not generate any grant statements, only the set owner statement.
Have also looked into has_table_privilege
but this doesn't seem to be the simplest course of action.