diff --git a/metadata-ingestion/src/datahub/ingestion/source/redshift/query.py b/metadata-ingestion/src/datahub/ingestion/source/redshift/query.py index 88db2d2dd0abf..1b684c61f796e 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/redshift/query.py +++ b/metadata-ingestion/src/datahub/ingestion/source/redshift/query.py @@ -13,11 +13,13 @@ class RedshiftQuery: list_schemas: str = """SELECT database_name, schema_name, schema_type, - usename as schema_owner_name, + -- setting user_name to null as we don't use it now now and it breaks backward compatibility due to additional permission need + -- usename as schema_owner_name, + null as schema_owner_name, schema_option, NULL::varchar(255) as external_database FROM SVV_REDSHIFT_SCHEMAS as s - inner join pg_catalog.pg_user_info as i on i.usesysid = s.schema_owner + -- inner join pg_catalog.pg_user_info as i on i.usesysid = s.schema_owner where schema_name !~ '^pg_' AND schema_name != 'information_schema' UNION ALL @@ -30,11 +32,13 @@ class RedshiftQuery: WHEN '4' THEN 'REDSHIFT' ELSE 'OTHER' END as schema_type, - usename as schema_owner_name, + -- setting user_name to null as we don't use it now now and it breaks backward compatibility due to additional permission need + -- usename as schema_owner_name, + null as schema_owner_name, esoptions as schema_option, databasename as external_database FROM SVV_EXTERNAL_SCHEMAS as s - inner join pg_catalog.pg_user_info as i on i.usesysid = s.esowner + -- inner join pg_catalog.pg_user_info as i on i.usesysid = s.esowner ORDER BY database_name, SCHEMA_NAME; """ @@ -57,7 +61,9 @@ class RedshiftQuery: WHEN 8 THEN 'ALL' END AS "diststyle", c.relowner AS "owner_id", - u.usename AS "owner_name", + -- setting user_name to null as we don't use it now now and it breaks backward compatibility due to additional permission need + -- u.usename AS "owner_name", + null as "owner_name", TRIM(TRAILING ';' FROM pg_catalog.pg_get_viewdef (c.oid,TRUE)) AS "view_definition", pg_catalog.array_to_string(c.relacl,'\n') AS "privileges", NULL as "location", @@ -70,7 +76,7 @@ class RedshiftQuery: LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace LEFT JOIN pg_class_info as ci on c.oid = ci.reloid LEFT JOIN pg_catalog.pg_description pgd ON pgd.objsubid = 0 AND pgd.objoid = c.oid - JOIN pg_catalog.pg_user u ON u.usesysid = c.relowner + -- JOIN pg_catalog.pg_user u ON u.usesysid = c.relowner WHERE c.relkind IN ('r','v','m','S','f') AND n.nspname !~ '^pg_' AND n.nspname != 'information_schema' @@ -383,14 +389,14 @@ def list_insert_create_queries_sql( stl_insert as si join SVV_TABLE_INFO sti on sti.table_id = tbl - left join pg_user pu on - pu.usesysid = si.userid + left join svl_user_info sui on + si.userid = sui.usesysid left join stl_query sq on si.query = sq.query left join stl_load_commits slc on slc.query = si.query where - pu.usename <> 'rdsdb' + sui.usename <> 'rdsdb' and sq.aborted = 0 and slc.query IS NULL and cluster = '{db_name}'