Skip to content

Commit

Permalink
Fix JmxMetadata#listTables
Browse files Browse the repository at this point in the history
When schemaNameOrNull is null the connector is expected to return all
tables it has. Jmx was returning no tables in this case.
  • Loading branch information
kokosing committed Apr 12, 2018
1 parent 2ccfa9b commit 508317a
Showing 1 changed file with 17 additions and 8 deletions.
Expand Up @@ -30,6 +30,7 @@
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder; import com.google.common.collect.ImmutableList.Builder;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Streams; import com.google.common.collect.Streams;


Expand Down Expand Up @@ -180,17 +181,25 @@ public ConnectorTableMetadata getTableMetadata(ConnectorSession session, Connect
@Override @Override
public List<SchemaTableName> listTables(ConnectorSession session, String schemaNameOrNull) public List<SchemaTableName> listTables(ConnectorSession session, String schemaNameOrNull)
{ {
if (JMX_SCHEMA_NAME.equals(schemaNameOrNull)) { Set<String> schemaNames;
return listJmxTables(); if (schemaNameOrNull != null) {
} schemaNames = ImmutableSet.of(schemaNameOrNull);
else if (HISTORY_SCHEMA_NAME.equals(schemaNameOrNull)) {
return jmxHistoricalData.getTables().stream()
.map(tableName -> new SchemaTableName(JmxMetadata.HISTORY_SCHEMA_NAME, tableName))
.collect(toList());
} }
else { else {
return ImmutableList.of(); schemaNames = ImmutableSet.copyOf(listSchemaNames(session));
}
ImmutableList.Builder<SchemaTableName> schemaTableNames = ImmutableList.builder();
for (String schema : schemaNames) {
if (JMX_SCHEMA_NAME.equals(schema)) {
return listJmxTables();
}
else if (HISTORY_SCHEMA_NAME.equals(schema)) {
return jmxHistoricalData.getTables().stream()
.map(tableName -> new SchemaTableName(JmxMetadata.HISTORY_SCHEMA_NAME, tableName))
.collect(toList());
}
} }
return schemaTableNames.build();
} }


private List<SchemaTableName> listJmxTables() private List<SchemaTableName> listJmxTables()
Expand Down

0 comments on commit 508317a

Please sign in to comment.