Skip to content

Commit

Permalink
Clarify comments around listing redirected tables
Browse files Browse the repository at this point in the history
  • Loading branch information
phd3 committed Oct 13, 2021
1 parent 15c0419 commit 611b468
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ public static Set<SchemaTableName> listTables(Session session, Metadata metadata
Set<SchemaTableName> tableNames = metadata.listTables(session, prefix).stream()
.map(QualifiedObjectName::asSchemaTableName)
.collect(toImmutableSet());

// Table listing operation only involves getting table names, but not any metadata. So redirected tables are not
// handled any differently. The target table or catalog are not involved. Thus the following filter is only called
// for the source catalog on source table names.
return accessControl.filterTables(session.toSecurityContext(), prefix.getCatalogName(), tableNames);
}

Expand Down Expand Up @@ -185,7 +189,8 @@ public static Map<SchemaTableName, List<ColumnMetadata>> listTableColumns(Sessio
boolean redirectionSucceeded = false;

try {
// Handle redirection before filterColumns check
// For redirected tables, column listing requires special handling, because the column metadata is unavailable
// at the source table, and needs to be fetched from the target table.
RedirectionAwareTableHandle redirection = metadata.getRedirectionAwareTableHandle(session, originalTableName);
targetTableName = redirection.getRedirectedTableName();

Expand Down Expand Up @@ -213,7 +218,7 @@ public static Map<SchemaTableName, List<ColumnMetadata>> listTableColumns(Sessio

Set<String> allowedColumns = accessControl.filterColumns(
session.toSecurityContext(),
// Use redirected table name for applying column filters
// Use redirected table name for applying column filters, since the source does not know the column metadata
targetTableName.orElse(originalTableName).asCatalogSchemaTableName(),
columns.stream()
.map(ColumnMetadata::getName)
Expand Down

0 comments on commit 611b468

Please sign in to comment.