use of com.amazonaws.athena.connector.lambda.metadata.ListTablesResponse 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());
}
use of com.amazonaws.athena.connector.lambda.metadata.ListTablesResponse in project aws-athena-query-federation by awslabs.
the class ListTablesResponseSerDeTest method beforeTest.
@Before
public void beforeTest() throws IOException {
expected = new ListTablesResponse("test-catalog", ImmutableList.of(new TableName("schema1", "table1"), new TableName("schema1", "table2")), "table3");
String expectedSerDeFile = utils.getResourceOrFail("serde/v2", "ListTablesResponse.json");
expectedSerDeText = utils.readAllAsString(expectedSerDeFile).trim();
}
use of com.amazonaws.athena.connector.lambda.metadata.ListTablesResponse in project aws-athena-query-federation by awslabs.
the class JdbcMetadataHandlerTest method doListTablesEscaped.
@Test
public void doListTablesEscaped() throws SQLException {
String[] schema = { "TABLE_SCHEM", "TABLE_NAME" };
Object[][] values = { { "test_Schema", "testTable" }, { "test_Schema", "testtable2" } };
TableName[] expected = { new TableName("test_Schema", "testTable"), new TableName("test_Schema", "testtable2") };
AtomicInteger rowNumber = new AtomicInteger(-1);
ResultSet resultSet = mockResultSet(schema, values, rowNumber);
Mockito.when(connection.getMetaData().getTables("testCatalog", "test\\_Schema", null, new String[] { "TABLE", "VIEW", "EXTERNAL TABLE" })).thenReturn(resultSet);
Mockito.when(connection.getCatalog()).thenReturn("testCatalog");
Mockito.when(connection.getMetaData().getSearchStringEscape()).thenReturn("\\");
ListTablesResponse listTablesResponse = this.jdbcMetadataHandler.doListTables(this.blockAllocator, new ListTablesRequest(this.federatedIdentity, "testQueryId", "testCatalog", "test_Schema", null, UNLIMITED_PAGE_SIZE_VALUE));
Assert.assertArrayEquals(expected, listTablesResponse.getTables().toArray());
}
use of com.amazonaws.athena.connector.lambda.metadata.ListTablesResponse in project aws-athena-query-federation by awslabs.
the class NeptuneMetadataHandler method doListTables.
/**
* Used to get the list of tables that this data source contains. In this case,
* fetch list of tables in the Glue database provided.
*
* @param allocator Tool for creating and managing Apache Arrow Blocks.
* @param request Provides details on who made the request and which Athena
* catalog and database they are querying.
* @return A ListTablesResponse which primarily contains a List<TableName>
* enumerating the tables in this catalog, database tuple. It also
* contains the catalog name corresponding the Athena catalog that was
* queried.
* @see GlueMetadataHandler
*/
@Override
public ListTablesResponse doListTables(BlockAllocator allocator, ListTablesRequest request) {
logger.info("doListTables: enter - " + request);
List<TableName> tables = new ArrayList<>();
GetTablesRequest getTablesRequest = new GetTablesRequest();
getTablesRequest.setDatabaseName(request.getSchemaName());
GetTablesResult getTablesResult = glue.getTables(getTablesRequest);
List<Table> glueTableList = getTablesResult.getTableList();
String schemaName = request.getSchemaName();
glueTableList.forEach(e -> {
tables.add(new TableName(schemaName, e.getName()));
});
return new ListTablesResponse(request.getCatalogName(), tables, null);
}
use of com.amazonaws.athena.connector.lambda.metadata.ListTablesResponse in project aws-athena-query-federation by awslabs.
the class TPCDSMetadataHandlerTest method doListTables.
@Test
public void doListTables() {
logger.info("doListTables - enter");
ListTablesRequest req = new ListTablesRequest(identity, "queryId", "default", "tpcds1", null, UNLIMITED_PAGE_SIZE_VALUE);
ListTablesResponse res = handler.doListTables(allocator, req);
logger.info("doListTables - {}", res.getTables());
assertTrue(res.getTables().contains(new TableName("tpcds1", "customer")));
assertTrue(res.getTables().size() == 25);
logger.info("doListTables - exit");
}
Aggregations