Skip to content

Commit

Permalink
Implement Optional-based connector metadata API in Tpcds
Browse files Browse the repository at this point in the history
  • Loading branch information
kokosing committed Jul 18, 2018
1 parent 9950359 commit 76ca7f8
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public ColumnMetadata getColumnMetadata(ConnectorSession session, ConnectorTable
public Map<SchemaTableName, List<ColumnMetadata>> listTableColumns(ConnectorSession session, SchemaTablePrefix prefix)
{
ImmutableMap.Builder<SchemaTableName, List<ColumnMetadata>> tableColumns = ImmutableMap.builder();
for (String schemaName : getSchemaNames(session, prefix.getSchemaName())) {
for (String schemaName : getSchemaNames(session, Optional.ofNullable(prefix.getSchemaName()))) {
for (Table tpcdsTable : Table.getBaseTables()) {
if (prefix.getTableName() == null || tpcdsTable.getName().equals(prefix.getTableName())) {
ConnectorTableMetadata tableMetadata = getTableMetadata(schemaName, tpcdsTable);
Expand All @@ -198,24 +198,24 @@ public Map<SchemaTableName, List<ColumnMetadata>> listTableColumns(ConnectorSess
}

@Override
public List<SchemaTableName> listTables(ConnectorSession session, String schemaNameOrNull)
public List<SchemaTableName> listTables(ConnectorSession session, Optional<String> filterSchema)
{
ImmutableList.Builder<SchemaTableName> builder = ImmutableList.builder();
for (String schemaName : getSchemaNames(session, schemaNameOrNull)) {
for (String schemaName : getSchemaNames(session, filterSchema)) {
for (Table tpcdsTable : Table.getBaseTables()) {
builder.add(new SchemaTableName(schemaName, tpcdsTable.getName()));
}
}
return builder.build();
}

private List<String> getSchemaNames(ConnectorSession session, String schemaNameOrNull)
private List<String> getSchemaNames(ConnectorSession session, Optional<String> schemaName)
{
if (schemaNameOrNull == null) {
if (!schemaName.isPresent()) {
return listSchemaNames(session);
}
else if (schemaNameToScaleFactor(schemaNameOrNull) > 0) {
return ImmutableList.of(schemaNameOrNull);
if (schemaNameToScaleFactor(schemaName.get()) > 0) {
return ImmutableList.of(schemaName.get());
}
return ImmutableList.of();
}
Expand Down

0 comments on commit 76ca7f8

Please sign in to comment.