Search in sources :

Example 11 with ListSchemasResponse

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

the class DynamoDBMetadataHandlerTest method doListSchemaNamesGlue.

@Test
public void doListSchemaNamesGlue() throws Exception {
    GetDatabasesResult result = new GetDatabasesResult().withDatabaseList(new Database().withName(DEFAULT_SCHEMA), new Database().withName("ddb").withLocationUri(DYNAMO_DB_FLAG), new Database().withName("s3").withLocationUri("blah"));
    when(glueClient.getDatabases(any())).thenReturn(result);
    ListSchemasRequest req = new ListSchemasRequest(TEST_IDENTITY, TEST_QUERY_ID, TEST_CATALOG_NAME);
    ListSchemasResponse res = handler.doListSchemaNames(allocator, req);
    logger.info("doListSchemas - {}", res.getSchemas());
    assertThat(res.getSchemas().size(), equalTo(2));
    assertThat(res.getSchemas().contains("default"), is(true));
    assertThat(res.getSchemas().contains("ddb"), is(true));
}
Also used : ListSchemasRequest(com.amazonaws.athena.connector.lambda.metadata.ListSchemasRequest) GetDatabasesResult(com.amazonaws.services.glue.model.GetDatabasesResult) Database(com.amazonaws.services.glue.model.Database) ListSchemasResponse(com.amazonaws.athena.connector.lambda.metadata.ListSchemasResponse) Test(org.junit.Test)

Example 12 with ListSchemasResponse

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

the class HbaseMetadataHandler method doListSchemaNames.

/**
 * List namespaces in your HBase instance treating each as a 'schema' (aka database)
 *
 * @see GlueMetadataHandler
 */
@Override
public ListSchemasResponse doListSchemaNames(BlockAllocator blockAllocator, ListSchemasRequest request) throws IOException {
    List<String> schemas = new ArrayList<>();
    NamespaceDescriptor[] namespaces = getOrCreateConn(request).listNamespaceDescriptors();
    for (int i = 0; i < namespaces.length; i++) {
        NamespaceDescriptor namespace = namespaces[i];
        schemas.add(namespace.getName());
    }
    return new ListSchemasResponse(request.getCatalogName(), schemas);
}
Also used : ArrayList(java.util.ArrayList) NamespaceDescriptor(org.apache.hadoop.hbase.NamespaceDescriptor) ListSchemasResponse(com.amazonaws.athena.connector.lambda.metadata.ListSchemasResponse)

Example 13 with ListSchemasResponse

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

the class ListSchemasResponseSerDeTest method deserialize.

@Test
public void deserialize() throws IOException {
    logger.info("deserialize: enter");
    InputStream input = new ByteArrayInputStream(expectedSerDeText.getBytes());
    ListSchemasResponse actual = (ListSchemasResponse) mapper.readValue(input, FederationResponse.class);
    logger.info("deserialize: deserialized[{}]", actual);
    assertEquals(expected, actual);
    logger.info("deserialize: exit");
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ListSchemasResponse(com.amazonaws.athena.connector.lambda.metadata.ListSchemasResponse) FederationResponse(com.amazonaws.athena.connector.lambda.request.FederationResponse) TypedSerDeTest(com.amazonaws.athena.connector.lambda.serde.TypedSerDeTest) Test(org.junit.Test)

Example 14 with ListSchemasResponse

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

the class ListSchemasResponseSerDeTest method beforeTest.

@Before
public void beforeTest() throws IOException {
    expected = new ListSchemasResponse("test-catalog", ImmutableList.of("schema1", "schema2"));
    String expectedSerDeFile = utils.getResourceOrFail("serde/v2", "ListSchemasResponse.json");
    expectedSerDeText = utils.readAllAsString(expectedSerDeFile).trim();
}
Also used : ListSchemasResponse(com.amazonaws.athena.connector.lambda.metadata.ListSchemasResponse) Before(org.junit.Before)

Example 15 with ListSchemasResponse

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

the class TPCDSMetadataHandlerTest method doListSchemaNames.

@Test
public void doListSchemaNames() {
    logger.info("doListSchemas - enter");
    ListSchemasRequest req = new ListSchemasRequest(identity, "queryId", "default");
    ListSchemasResponse res = handler.doListSchemaNames(allocator, req);
    logger.info("doListSchemas - {}", res.getSchemas());
    assertTrue(res.getSchemas().size() == 5);
    logger.info("doListSchemas - exit");
}
Also used : ListSchemasRequest(com.amazonaws.athena.connector.lambda.metadata.ListSchemasRequest) ListSchemasResponse(com.amazonaws.athena.connector.lambda.metadata.ListSchemasResponse) Test(org.junit.Test)

Aggregations

ListSchemasResponse (com.amazonaws.athena.connector.lambda.metadata.ListSchemasResponse)26 ListSchemasRequest (com.amazonaws.athena.connector.lambda.metadata.ListSchemasRequest)16 Test (org.junit.Test)15 ArrayList (java.util.ArrayList)11 GetSplitsResponse (com.amazonaws.athena.connector.lambda.metadata.GetSplitsResponse)3 GetTableLayoutResponse (com.amazonaws.athena.connector.lambda.metadata.GetTableLayoutResponse)3 GetTableResponse (com.amazonaws.athena.connector.lambda.metadata.GetTableResponse)3 ListTablesResponse (com.amazonaws.athena.connector.lambda.metadata.ListTablesResponse)3 Database (com.amazonaws.services.glue.model.Database)3 GetDatabasesResult (com.amazonaws.services.glue.model.GetDatabasesResult)3 BlockAllocatorImpl (com.amazonaws.athena.connector.lambda.data.BlockAllocatorImpl)2 TableName (com.amazonaws.athena.connector.lambda.domain.TableName)2 ReadRecordsResponse (com.amazonaws.athena.connector.lambda.records.ReadRecordsResponse)2 GetDatabasesRequest (com.amazonaws.services.glue.model.GetDatabasesRequest)2 DescribeLogGroupsRequest (com.amazonaws.services.logs.model.DescribeLogGroupsRequest)2 DescribeLogGroupsResult (com.amazonaws.services.logs.model.DescribeLogGroupsResult)2 Database (com.amazonaws.services.timestreamwrite.model.Database)2 ListDatabasesRequest (com.amazonaws.services.timestreamwrite.model.ListDatabasesRequest)2 ListDatabasesResult (com.amazonaws.services.timestreamwrite.model.ListDatabasesResult)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2