Search in sources :

Example 1 with MetadataRequestType

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

GetSplitsResponse (com.amazonaws.athena.connector.lambda.metadata.GetSplitsResponse)1 GetTableLayoutResponse (com.amazonaws.athena.connector.lambda.metadata.GetTableLayoutResponse)1 GetTableResponse (com.amazonaws.athena.connector.lambda.metadata.GetTableResponse)1 ListSchemasResponse (com.amazonaws.athena.connector.lambda.metadata.ListSchemasResponse)1 ListTablesResponse (com.amazonaws.athena.connector.lambda.metadata.ListTablesResponse)1 MetadataRequestType (com.amazonaws.athena.connector.lambda.metadata.MetadataRequestType)1