Search in sources :

Example 6 with ListTablesRequest

use of com.amazonaws.athena.connector.lambda.metadata.ListTablesRequest in project aws-athena-query-federation by awslabs.

the class JdbcMetadataHandlerTest method doListTablesSQLException.

@Test(expected = RuntimeException.class)
public void doListTablesSQLException() throws SQLException {
    Mockito.when(this.connection.getMetaData().getTables(Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.any())).thenThrow(new SQLException());
    this.jdbcMetadataHandler.doListTables(this.blockAllocator, new ListTablesRequest(this.federatedIdentity, "testQueryId", "testCatalog", "testSchema", null, UNLIMITED_PAGE_SIZE_VALUE));
}
Also used : SQLException(java.sql.SQLException) ListTablesRequest(com.amazonaws.athena.connector.lambda.metadata.ListTablesRequest) Test(org.junit.Test)

Example 7 with ListTablesRequest

use of com.amazonaws.athena.connector.lambda.metadata.ListTablesRequest in project aws-athena-query-federation by awslabs.

the class JdbcMetadataHandlerTest method doListTables.

@Test
public void doListTables() throws SQLException {
    String[] schema = { "TABLE_SCHEM", "TABLE_NAME" };
    Object[][] values = { { "testSchema", "testTable" }, { "testSchema", "testtable2" } };
    TableName[] expected = { new TableName("testSchema", "testTable"), new TableName("testSchema", "testtable2") };
    AtomicInteger rowNumber = new AtomicInteger(-1);
    ResultSet resultSet = mockResultSet(schema, values, rowNumber);
    Mockito.when(connection.getMetaData().getTables("testCatalog", "testSchema", null, new String[] { "TABLE", "VIEW", "EXTERNAL TABLE" })).thenReturn(resultSet);
    Mockito.when(connection.getCatalog()).thenReturn("testCatalog");
    ListTablesResponse listTablesResponse = this.jdbcMetadataHandler.doListTables(this.blockAllocator, new ListTablesRequest(this.federatedIdentity, "testQueryId", "testCatalog", "testSchema", null, UNLIMITED_PAGE_SIZE_VALUE));
    Assert.assertArrayEquals(expected, listTablesResponse.getTables().toArray());
}
Also used : TableName(com.amazonaws.athena.connector.lambda.domain.TableName) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ResultSet(java.sql.ResultSet) ListTablesRequest(com.amazonaws.athena.connector.lambda.metadata.ListTablesRequest) ListTablesResponse(com.amazonaws.athena.connector.lambda.metadata.ListTablesResponse) Test(org.junit.Test)

Example 8 with ListTablesRequest

use of com.amazonaws.athena.connector.lambda.metadata.ListTablesRequest in project aws-athena-query-federation by awslabs.

the class MultiplexingJdbcMetadataHandlerTest 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.fakeDatabaseHandler, Mockito.times(1)).doListTables(Mockito.eq(this.allocator), Mockito.eq(listTablesRequest));
}
Also used : ListTablesRequest(com.amazonaws.athena.connector.lambda.metadata.ListTablesRequest) Test(org.junit.Test)

Example 9 with ListTablesRequest

use of com.amazonaws.athena.connector.lambda.metadata.ListTablesRequest in project aws-athena-query-federation by awslabs.

the class PostGreSqlMuxJdbcMetadataHandlerTest method doListTables.

@Test
public void doListTables() {
    ListTablesRequest listTablesRequest = Mockito.mock(ListTablesRequest.class);
    Mockito.when(listTablesRequest.getCatalogName()).thenReturn("postgres");
    this.jdbcMetadataHandler.doListTables(this.allocator, listTablesRequest);
    Mockito.verify(this.postGreSqlMetadataHandler, Mockito.times(1)).doListTables(Mockito.eq(this.allocator), Mockito.eq(listTablesRequest));
}
Also used : ListTablesRequest(com.amazonaws.athena.connector.lambda.metadata.ListTablesRequest) Test(org.junit.Test)

Example 10 with ListTablesRequest

use of com.amazonaws.athena.connector.lambda.metadata.ListTablesRequest in project aws-athena-query-federation by awslabs.

the class NeptuneMetadataHandlerTest method doListTables.

@Test
public void doListTables() {
    logger.info("doListTables - enter");
    List<Table> tables = new ArrayList<Table>();
    Table table1 = new Table();
    table1.setName("table1");
    Table table2 = new Table();
    table2.setName("table2");
    Table table3 = new Table();
    table3.setName("table3");
    tables.add(table1);
    tables.add(table2);
    tables.add(table3);
    GetTablesResult tableResult = new GetTablesResult();
    tableResult.setTableList(tables);
    ListTablesRequest req = new ListTablesRequest(IDENTITY, "queryId", "default", "default", null, UNLIMITED_PAGE_SIZE_VALUE);
    when(glue.getTables(any(GetTablesRequest.class))).thenReturn(tableResult);
    ListTablesResponse res = handler.doListTables(allocator, req);
    logger.info("doListTables - {}", res.getTables());
    assertFalse(res.getTables().isEmpty());
    logger.info("doListTables - exit");
}
Also used : Table(com.amazonaws.services.glue.model.Table) GetTablesResult(com.amazonaws.services.glue.model.GetTablesResult) ArrayList(java.util.ArrayList) ListTablesRequest(com.amazonaws.athena.connector.lambda.metadata.ListTablesRequest) ListTablesResponse(com.amazonaws.athena.connector.lambda.metadata.ListTablesResponse) GetTablesRequest(com.amazonaws.services.glue.model.GetTablesRequest) Test(org.junit.Test)

Aggregations

ListTablesRequest (com.amazonaws.athena.connector.lambda.metadata.ListTablesRequest)33 Test (org.junit.Test)31 ListTablesResponse (com.amazonaws.athena.connector.lambda.metadata.ListTablesResponse)17 TableName (com.amazonaws.athena.connector.lambda.domain.TableName)13 ArrayList (java.util.ArrayList)5 ImmutableList (com.google.common.collect.ImmutableList)4 SchemaBuilder (com.amazonaws.athena.connector.lambda.data.SchemaBuilder)3 BlockAllocatorImpl (com.amazonaws.athena.connector.lambda.data.BlockAllocatorImpl)2 GetTablesResult (com.amazonaws.services.glue.model.GetTablesResult)2 Table (com.amazonaws.services.glue.model.Table)2 Matchers.anyString (org.mockito.Matchers.anyString)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 AmazonServiceException (com.amazonaws.AmazonServiceException)1 BlockAllocator (com.amazonaws.athena.connector.lambda.data.BlockAllocator)1 Split (com.amazonaws.athena.connector.lambda.domain.Split)1 Constraints (com.amazonaws.athena.connector.lambda.domain.predicate.Constraints)1 EquatableValueSet (com.amazonaws.athena.connector.lambda.domain.predicate.EquatableValueSet)1 Range (com.amazonaws.athena.connector.lambda.domain.predicate.Range)1 SortedRangeSet (com.amazonaws.athena.connector.lambda.domain.predicate.SortedRangeSet)1 ValueSet (com.amazonaws.athena.connector.lambda.domain.predicate.ValueSet)1