Search in sources :

Example 31 with ListTablesResponse

use of com.amazonaws.athena.connector.lambda.metadata.ListTablesResponse 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

ListTablesResponse (com.amazonaws.athena.connector.lambda.metadata.ListTablesResponse)31 TableName (com.amazonaws.athena.connector.lambda.domain.TableName)24 ListTablesRequest (com.amazonaws.athena.connector.lambda.metadata.ListTablesRequest)18 Test (org.junit.Test)17 ArrayList (java.util.ArrayList)13 Table (com.amazonaws.services.glue.model.Table)5 SchemaBuilder (com.amazonaws.athena.connector.lambda.data.SchemaBuilder)4 GetSplitsResponse (com.amazonaws.athena.connector.lambda.metadata.GetSplitsResponse)4 GetTableLayoutResponse (com.amazonaws.athena.connector.lambda.metadata.GetTableLayoutResponse)4 GetTableResponse (com.amazonaws.athena.connector.lambda.metadata.GetTableResponse)4 ListSchemasResponse (com.amazonaws.athena.connector.lambda.metadata.ListSchemasResponse)4 GetTablesResult (com.amazonaws.services.glue.model.GetTablesResult)4 ImmutableList (com.google.common.collect.ImmutableList)4 BlockAllocatorImpl (com.amazonaws.athena.connector.lambda.data.BlockAllocatorImpl)3 Before (org.junit.Before)3 BlockAllocator (com.amazonaws.athena.connector.lambda.data.BlockAllocator)2 Split (com.amazonaws.athena.connector.lambda.domain.Split)2 Constraints (com.amazonaws.athena.connector.lambda.domain.predicate.Constraints)2 GetSplitsRequest (com.amazonaws.athena.connector.lambda.metadata.GetSplitsRequest)2 GetTableLayoutRequest (com.amazonaws.athena.connector.lambda.metadata.GetTableLayoutRequest)2