use of com.amazonaws.athena.connectors.dynamodb.constants.DynamoDBConstants.DEFAULT_SCHEMA in project aws-athena-query-federation by awslabs.
the class DynamoDBMetadataHandlerTest method doListTablesGlueAndDynamo.
@Test
public void doListTablesGlueAndDynamo() throws Exception {
List<String> tableNames = new ArrayList<>();
tableNames.add("table1");
tableNames.add("table2");
tableNames.add("table3");
GetTablesResult mockResult = new GetTablesResult();
List<Table> tableList = new ArrayList<>();
tableList.add(new Table().withName("table1").withParameters(ImmutableMap.of("classification", "dynamodb")).withStorageDescriptor(new StorageDescriptor().withLocation("some.location")));
tableList.add(new Table().withName("table2").withParameters(ImmutableMap.of()).withStorageDescriptor(new StorageDescriptor().withLocation("some.location").withParameters(ImmutableMap.of("classification", "dynamodb"))));
tableList.add(new Table().withName("table3").withParameters(ImmutableMap.of()).withStorageDescriptor(new StorageDescriptor().withLocation("arn:aws:dynamodb:us-east-1:012345678910:table/table3")));
tableList.add(new Table().withName("notADynamoTable").withParameters(ImmutableMap.of()).withStorageDescriptor(new StorageDescriptor().withParameters(ImmutableMap.of()).withLocation("some_location")));
mockResult.setTableList(tableList);
when(glueClient.getTables(any())).thenReturn(mockResult);
ListTablesRequest req = new ListTablesRequest(TEST_IDENTITY, TEST_QUERY_ID, TEST_CATALOG_NAME, DEFAULT_SCHEMA, null, UNLIMITED_PAGE_SIZE_VALUE);
ListTablesResponse res = handler.doListTables(allocator, req);
logger.info("doListTables - {}", res.getTables());
List<TableName> expectedTables = tableNames.stream().map(table -> new TableName(DEFAULT_SCHEMA, table)).collect(Collectors.toList());
expectedTables.add(TEST_TABLE_NAME);
expectedTables.add(new TableName(DEFAULT_SCHEMA, "test_table2"));
expectedTables.add(new TableName(DEFAULT_SCHEMA, "test_table3"));
expectedTables.add(new TableName(DEFAULT_SCHEMA, "test_table4"));
assertThat(new HashSet<>(res.getTables()), equalTo(new HashSet<>(expectedTables)));
}
Aggregations