### Question:
DynamoDBMetadataHandler extends GlueMetadataHandler { @Override public GetTableResponse doGetTable(BlockAllocator allocator, GetTableRequest request) throws Exception { if (glueClient != null) { try { return super.doGetTable(allocator, request); } catch (RuntimeException e) { logger.warn("doGetTable: Unable to retrieve table {} from AWSGlue in database/schema {}. " + "Falling back to schema inference. If inferred schema is incorrect, create " + "a matching table in Glue to define schema (see README)", request.getTableName().getTableName(), request.getTableName().getSchemaName(), e); } } Schema schema = tableResolver.getTableSchema(request.getTableName().getTableName()); return new GetTableResponse(request.getCatalogName(), request.getTableName(), schema); } DynamoDBMetadataHandler(); @VisibleForTesting  DynamoDBMetadataHandler(EncryptionKeyFactory keyFactory,
            AWSSecretsManager secretsManager,
            AmazonAthena athena,
            String spillBucket,
            String spillPrefix,
            AmazonDynamoDB ddbClient,
            AWSGlue glueClient); @Override ListSchemasResponse doListSchemaNames(BlockAllocator allocator, ListSchemasRequest request); @Override ListTablesResponse doListTables(BlockAllocator allocator, ListTablesRequest request); @Override GetTableResponse doGetTable(BlockAllocator allocator, GetTableRequest request); @Override void enhancePartitionSchema(SchemaBuilder partitionSchemaBuilder, GetTableLayoutRequest request); @Override void getPartitions(BlockWriter blockWriter, GetTableLayoutRequest request, QueryStatusChecker queryStatusChecker); @Override GetSplitsResponse doGetSplits(BlockAllocator allocator, GetSplitsRequest request);  }### Answer:
@Test public void doGetTable() throws Exception { when(glueClient.getTable(any())).thenThrow(new AmazonServiceException("")); GetTableRequest req = new GetTableRequest(TEST_IDENTITY, TEST_QUERY_ID, TEST_CATALOG_NAME, TEST_TABLE_NAME); GetTableResponse res = handler.doGetTable(allocator, req); logger.info("doGetTable - {}", res.getSchema()); assertThat(res.getTableName().getSchemaName(), equalTo(DEFAULT_SCHEMA)); assertThat(res.getTableName().getTableName(), equalTo(TEST_TABLE)); assertThat(res.getSchema().getFields().size(), equalTo(11)); }
@Test public void doGetEmptyTable() throws Exception { when(glueClient.getTable(any())).thenThrow(new AmazonServiceException("")); GetTableRequest req = new GetTableRequest(TEST_IDENTITY, TEST_QUERY_ID, TEST_CATALOG_NAME, TEST_TABLE_2_NAME); GetTableResponse res = handler.doGetTable(allocator, req); logger.info("doGetEmptyTable - {}", res.getSchema()); assertThat(res.getTableName(), equalTo(TEST_TABLE_2_NAME)); assertThat(res.getSchema().getFields().size(), equalTo(2)); }
@Test public void testCaseInsensitiveResolve() throws Exception { when(glueClient.getTable(any())).thenThrow(new AmazonServiceException("")); GetTableRequest req = new GetTableRequest(TEST_IDENTITY, TEST_QUERY_ID, TEST_CATALOG_NAME, TEST_TABLE_2_NAME); GetTableResponse res = handler.doGetTable(allocator, req); logger.info("doGetTable - {}", res.getSchema()); assertThat(res.getTableName(), equalTo(TEST_TABLE_2_NAME)); }