Skip to content

Commit

Permalink
Fix param name in MockConnector listTables lambdas
Browse files Browse the repository at this point in the history
`listTables` is never called with a null schema name.
  • Loading branch information
findepi committed Nov 22, 2022
1 parent 99ba500 commit b362da8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public TestInformationSchemaMetadata()
LocalQueryRunner queryRunner = LocalQueryRunner.create(TEST_SESSION);
MockConnectorFactory mockConnectorFactory = MockConnectorFactory.builder()
.withListSchemaNames(connectorSession -> ImmutableList.of("test_schema"))
.withListTables((connectorSession, schemaNameOrNull) ->
.withListTables((connectorSession, schemaName) ->
ImmutableList.of(
new SchemaTableName("test_schema", "test_view"),
new SchemaTableName("test_schema", "another_table")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,12 @@ public Iterable<ConnectorFactory> getConnectorFactories()
.map(i -> "stream_" + i)
.collect(toImmutableList());

BiFunction<ConnectorSession, String, List<SchemaTableName>> listTables = (session, schemaNameOrNull) -> {
BiFunction<ConnectorSession, String, List<SchemaTableName>> listTables = (session, schemaName) -> {
List<String> tables = IntStream.range(0, Integer.parseInt(tablesCount))
.boxed()
.map(i -> "table_" + i)
.collect(toImmutableList());
List<String> schemas;
if (schemaNameOrNull == null) {
schemas = listSchemaNames.apply(session);
}
else {
schemas = ImmutableList.of(schemaNameOrNull);
}
return schemas.stream()
.flatMap(schema -> tables.stream().map(table -> new SchemaTableName(schema, table)))
return tables.stream().map(table -> new SchemaTableName(schemaName, table))
.collect(toImmutableList());
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public Iterable<ConnectorFactory> getConnectorFactories()

return new MockConnectorTableHandle(schemaTableName);
})
.withListTables((session, schemaNameOrNull) ->
.withListTables((session, schemaName) ->
ImmutableList.of(new SchemaTableName("UPPER_CASE_SCHEMA", "UPPER_CASE_TABLE")))
.withGetViews((session, prefix) -> ImmutableMap.of(viewTableName, getConnectorViewDefinition()))
.build();
Expand Down

0 comments on commit b362da8

Please sign in to comment.