- AWS Code Sample demonstrates how to delete a named query by using the named query ID.

package aws.example.athena; import; import; import; import; import; /** * DeleteNamedQueryExample * ------------------------------------- * This code shows how to delete a named query by using the named query ID. */ public class DeleteNamedQueryExample { private static String getNamedQueryId(AmazonAthena athenaClient) { // Create the NameQuery Request. CreateNamedQueryRequest createNamedQueryRequest = new CreateNamedQueryRequest() .withDatabase(ExampleConstants.ATHENA_DEFAULT_DATABASE) .withQueryString(ExampleConstants.ATHENA_SAMPLE_QUERY) .withName("SampleQueryName") .withDescription("Sample Description"); // Create the named query. If it fails, an exception is thrown. CreateNamedQueryResult createNamedQueryResult = athenaClient.createNamedQuery(createNamedQueryRequest); return createNamedQueryResult.getNamedQueryId(); } public static void main(String[] args) throws Exception { // Build an Athena client AthenaClientFactory factory = new AthenaClientFactory(); AmazonAthena athenaClient = factory.createClient(); String sampleNamedQueryId = getNamedQueryId(athenaClient); // Create the delete named query request DeleteNamedQueryRequest deleteNamedQueryRequest = new DeleteNamedQueryRequest() .withNamedQueryId(sampleNamedQueryId); // Delete the named query DeleteNamedQueryResult deleteNamedQueryResult = athenaClient.deleteNamedQuery(deleteNamedQueryRequest); } }

Sample Details

Service: athena

Last tested: 2018-06-25

Author: soo-aws

Type: full-example