Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: postgres priviledge check for redshift #9343

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,25 @@ public Set<String> getExcludedInternalNameSpaces() {
return Set.of("information_schema", "pg_catalog", "pg_internal", "catalog_history");
}

@Override
public Set<JdbcPrivilegeDto> 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);
Expand Down