Skip to content

Commit

Permalink
Add redirections support to Hive streamTableColumns
Browse files Browse the repository at this point in the history
  • Loading branch information
losipiuk committed Oct 22, 2021
1 parent e43496b commit f60f356
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,9 @@ public Stream<TableColumnsMetadata> streamTableColumns(ConnectorSession session,
requireNonNull(prefix, "prefix is null");
return listTables(session, prefix).stream().flatMap(tableName -> {
try {
if (redirectTable(session, tableName).isPresent()) {
return Stream.of(TableColumnsMetadata.forRedirectedTable(tableName));
}
return Stream.of(TableColumnsMetadata.forTable(tableName, getTableMetadata(session, tableName).getColumns()));
}
catch (HiveViewNotSupportedException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3098,12 +3098,12 @@ public void testIllegalStorageFormatDuringTableScan()
}
}

private Map<SchemaTableName, List<ColumnMetadata>> listTableColumns(ConnectorMetadata metadata, ConnectorSession session, SchemaTablePrefix prefix)
private static Map<SchemaTableName, List<ColumnMetadata>> listTableColumns(ConnectorMetadata metadata, ConnectorSession session, SchemaTablePrefix prefix)
{
return metadata.streamTableColumns(session, prefix)
.collect(toImmutableMap(
TableColumnsMetadata::getTable,
tableColumns -> tableColumns.getColumns().orElseThrow(() -> new IllegalStateException("Table " + tableColumns.getTable() + " reported as redirect target"))));
tableColumns -> tableColumns.getColumns().orElseThrow(() -> new IllegalStateException("Table " + tableColumns.getTable() + " reported as redirected"))));
}

private void createDummyTable(SchemaTableName tableName)
Expand Down

0 comments on commit f60f356

Please sign in to comment.