use of com.amazonaws.athena.connector.lambda.metadata.ListTablesRequest in project aws-athena-query-federation by awslabs.
the class HiveMuxMetadataHandlerTest method doListTables.
@Test
public void doListTables() {
ListTablesRequest listTablesRequest = Mockito.mock(ListTablesRequest.class);
Mockito.when(listTablesRequest.getCatalogName()).thenReturn("metaHive");
this.jdbcMetadataHandler.doListTables(this.allocator, listTablesRequest);
Mockito.verify(this.hiveMetadataHandler, Mockito.times(1)).doListTables(Mockito.eq(this.allocator), Mockito.eq(listTablesRequest));
}
use of com.amazonaws.athena.connector.lambda.metadata.ListTablesRequest in project aws-athena-query-federation by awslabs.
the class DataLakeGen2MuxMetadataHandlerTest method doListTables.
@Test
public void doListTables() {
ListTablesRequest listTablesRequest = Mockito.mock(ListTablesRequest.class);
Mockito.when(listTablesRequest.getCatalogName()).thenReturn("fakedatabase");
this.jdbcMetadataHandler.doListTables(this.allocator, listTablesRequest);
Mockito.verify(this.dataLakeGen2MetadataHandler, Mockito.times(1)).doListTables(Mockito.eq(this.allocator), Mockito.eq(listTablesRequest));
}
use of com.amazonaws.athena.connector.lambda.metadata.ListTablesRequest 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)));
}
use of com.amazonaws.athena.connector.lambda.metadata.ListTablesRequest in project aws-athena-query-federation by awslabs.
the class ExampleMetadataHandlerTest method doListTables.
@Test
public void doListTables() {
logger.info("doListTables - enter");
// Test request with unlimited page size
logger.info("doListTables - Test unlimited page size");
ListTablesRequest req = new ListTablesRequest(IdentityUtil.fakeIdentity(), "queryId", "default", "schema", null, UNLIMITED_PAGE_SIZE_VALUE);
ListTablesResponse expectedResponse = new ListTablesResponse("default", new ImmutableList.Builder<TableName>().add(new TableName("schema", "table1")).add(new TableName("schema", "table2")).add(new TableName("schema", "table3")).add(new TableName("schema", "table4")).add(new TableName("schema", "table5")).build(), null);
ObjectMapperUtil.assertSerialization(req);
ListTablesResponse res = metadataHandler.doListTables(allocator, req);
ObjectMapperUtil.assertSerialization(res);
logger.info("doListTables - {}", res);
assertEquals("Expecting a different response", expectedResponse, res);
// Test first paginated request with pageSize: 3, nextToken: null
logger.info("doListTables - Test first pagination request");
req = new ListTablesRequest(IdentityUtil.fakeIdentity(), "queryId", "default", "schema", null, 3);
expectedResponse = new ListTablesResponse("default", new ImmutableList.Builder<TableName>().add(new TableName("schema", "table1")).add(new TableName("schema", "table2")).add(new TableName("schema", "table3")).build(), "table4");
ObjectMapperUtil.assertSerialization(req);
res = metadataHandler.doListTables(allocator, req);
ObjectMapperUtil.assertSerialization(res);
logger.info("doListTables - {}", res);
assertEquals("Expecting a different response", expectedResponse, res);
// Test second paginated request with pageSize: 3, nextToken: res.getNextToken()
logger.info("doListTables - Test second pagination request");
req = new ListTablesRequest(IdentityUtil.fakeIdentity(), "queryId", "default", "schema", res.getNextToken(), 3);
expectedResponse = new ListTablesResponse("default", new ImmutableList.Builder<TableName>().add(new TableName("schema", "table4")).add(new TableName("schema", "table5")).build(), null);
ObjectMapperUtil.assertSerialization(req);
res = metadataHandler.doListTables(allocator, req);
ObjectMapperUtil.assertSerialization(res);
logger.info("doListTables - {}", res);
assertEquals("Expecting a different response", expectedResponse, res);
logger.info("doListTables - exit");
}
use of com.amazonaws.athena.connector.lambda.metadata.ListTablesRequest in project aws-athena-query-federation by awslabs.
the class HbaseMetadataHandlerTest method doListTables.
@Test
public void doListTables() throws IOException {
logger.info("doListTables - enter");
String schema = "schema1";
org.apache.hadoop.hbase.TableName[] tables = { org.apache.hadoop.hbase.TableName.valueOf("schema1", "table1"), org.apache.hadoop.hbase.TableName.valueOf("schema1", "table2"), org.apache.hadoop.hbase.TableName.valueOf("schema1", "table3") };
Set<String> tableNames = new HashSet<>();
tableNames.add("table1");
tableNames.add("table2");
tableNames.add("table3");
when(mockClient.listTableNamesByNamespace(eq(schema))).thenReturn(tables);
ListTablesRequest req = new ListTablesRequest(IDENTITY, QUERY_ID, DEFAULT_CATALOG, schema, null, UNLIMITED_PAGE_SIZE_VALUE);
ListTablesResponse res = handler.doListTables(allocator, req);
logger.info("doListTables - {}", res.getTables());
for (TableName next : res.getTables()) {
assertEquals(schema, next.getSchemaName());
assertTrue(tableNames.contains(next.getTableName()));
}
assertEquals(tableNames.size(), res.getTables().size());
}
Aggregations