Search in sources :

Example 26 with ListSchemasResponse

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

the class MetadataHandler method doHandleRequest.

protected final void doHandleRequest(BlockAllocator allocator, ObjectMapper objectMapper, MetadataRequest req, OutputStream outputStream) throws Exception {
    logger.info("doHandleRequest: request[{}]", req);
    MetadataRequestType type = req.getRequestType();
    switch(type) {
        case LIST_SCHEMAS:
            try (ListSchemasResponse response = doListSchemaNames(allocator, (ListSchemasRequest) req)) {
                logger.info("doHandleRequest: response[{}]", response);
                assertNotNull(response);
                objectMapper.writeValue(outputStream, response);
            }
            return;
        case LIST_TABLES:
            try (ListTablesResponse response = doListTables(allocator, (ListTablesRequest) req)) {
                logger.info("doHandleRequest: response[{}]", response);
                assertNotNull(response);
                objectMapper.writeValue(outputStream, response);
            }
            return;
        case GET_TABLE:
            try (GetTableResponse response = doGetTable(allocator, (GetTableRequest) req)) {
                logger.info("doHandleRequest: response[{}]", response);
                assertNotNull(response);
                assertTypes(response);
                objectMapper.writeValue(outputStream, response);
            }
            return;
        case GET_TABLE_LAYOUT:
            try (GetTableLayoutResponse response = doGetTableLayout(allocator, (GetTableLayoutRequest) req)) {
                logger.info("doHandleRequest: response[{}]", response);
                assertNotNull(response);
                objectMapper.writeValue(outputStream, response);
            }
            return;
        case GET_SPLITS:
            verifier.checkBucketAuthZ(spillBucket);
            try (GetSplitsResponse response = doGetSplits(allocator, (GetSplitsRequest) req)) {
                logger.info("doHandleRequest: response[{}]", response);
                assertNotNull(response);
                objectMapper.writeValue(outputStream, response);
            }
            return;
        default:
            throw new IllegalArgumentException("Unknown request type " + type);
    }
}
Also used : GetTableLayoutResponse(com.amazonaws.athena.connector.lambda.metadata.GetTableLayoutResponse) MetadataRequestType(com.amazonaws.athena.connector.lambda.metadata.MetadataRequestType) GetTableResponse(com.amazonaws.athena.connector.lambda.metadata.GetTableResponse) GetSplitsResponse(com.amazonaws.athena.connector.lambda.metadata.GetSplitsResponse) ListSchemasResponse(com.amazonaws.athena.connector.lambda.metadata.ListSchemasResponse) ListTablesResponse(com.amazonaws.athena.connector.lambda.metadata.ListTablesResponse)

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