diff --git a/airbyte-integrations/connectors/source-redshift/src/main/java/io/airbyte/integrations/source/redshift/RedshiftSource.java b/airbyte-integrations/connectors/source-redshift/src/main/java/io/airbyte/integrations/source/redshift/RedshiftSource.java index f1196d9e5e2f5..e01bb1daafa40 100644 --- a/airbyte-integrations/connectors/source-redshift/src/main/java/io/airbyte/integrations/source/redshift/RedshiftSource.java +++ b/airbyte-integrations/connectors/source-redshift/src/main/java/io/airbyte/integrations/source/redshift/RedshiftSource.java @@ -56,6 +56,25 @@ public Set getExcludedInternalNameSpaces() { return Set.of("information_schema", "pg_catalog", "pg_internal", "catalog_history"); } + @Override + public Set getPrivilegesTableForCurrentUser(final JdbcDatabase database, final String schema) throws SQLException { + return database.query(connection -> { + final PreparedStatement ps = connection.prepareStatement( + "SELECT DISTINCT table_catalog, table_schema, table_name, privilege_type\n" + + "FROM information_schema.table_privileges\n" + + "WHERE grantee = ? AND privilege_type = 'SELECT'"); + ps.setString(1, database.getDatabaseConfig().get("username").asText()); + return ps; + }, sourceOperations::rowToJson) + .collect(toSet()) + .stream() + .map(e -> JdbcPrivilegeDto.builder() + .schemaName(e.get("table_schema").asText()) + .tableName(e.get("table_name").asText()) + .build()) + .collect(toSet()); + } + public static void main(final String[] args) throws Exception { final Source source = new RedshiftSource(); LOGGER.info("starting source: {}", RedshiftSource.class);