public static List <Dictionary <String, String> > runQuery(String StrQuery) { var client = new AmazonAthenaClient("AKIAWR5GGX5MW7QKSAWV", "jEdL+v3zQa8oTg/3Pkx0nd9+y3j5ZUP9AULNRW/H", Amazon.RegionEndpoint.APSouth1); QueryExecutionContext qContext = new QueryExecutionContext(); qContext.Database = ATHENA_DB; ResultConfiguration resConf = new ResultConfiguration(); resConf.OutputLocation = ATHENA_TEMP_PATH; List <Dictionary <String, String> > items = new List <Dictionary <String, String> >(); try { /* Execute a simple query on a table */ StartQueryExecutionRequest qReq = new StartQueryExecutionRequest() { QueryString = StrQuery, QueryExecutionContext = qContext, ResultConfiguration = resConf }; /* Executes the query in an async manner */ StartQueryExecutionResponse qRes = client.StartQueryExecution(qReq); // await client.StartQueryExecutionAsync(qReq); /* Call internal method to parse the results and return a list of key/value dictionaries */ items = getQueryExecution(client, qRes.QueryExecutionId); //await getQueryExecution(client, qRes.QueryExecutionId); } catch (InvalidRequestException e) { Console.WriteLine("Run Error: {0}", e.Message); } return(items); }
public AWSAthenaAPI(AWSAthenaOptions awsAthenaOptions) { this.awsAthenaOptions = awsAthenaOptions; basicAWSCredentials = new BasicAWSCredentials(awsAthenaOptions.Key, awsAthenaOptions.Secret); amazonAthenaClient = new AmazonAthenaClient(basicAWSCredentials, RegionEndpoint.GetBySystemName(awsAthenaOptions.Region)); DefaultOutputLocation = awsAthenaOptions.DefaultOutputLocation; }
/** * Wait for an Athena query to complete, fail or to be cancelled. This is done by polling Athena over an * interval of time. If a query fails or is cancelled, then it will throw an exception. */ private static void waitForQueryToComplete(AmazonAthenaClient athenaClient, String queryExecutionId) { var getQueryExecutionRequest = new GetQueryExecutionRequest() { QueryExecutionId = queryExecutionId }; GetQueryExecutionResponse getQueryExecutionResponse = null; bool isQueryStillRunning = true; while (isQueryStillRunning) { getQueryExecutionResponse = athenaClient.GetQueryExecution(getQueryExecutionRequest); var queryState = getQueryExecutionResponse.QueryExecution.Status.State; if (queryState == QueryExecutionState.FAILED) { throw new Exception("Query Failed to run with Error Message: " + getQueryExecutionResponse.QueryExecution.Status.StateChangeReason); } else if (queryState == QueryExecutionState.CANCELLED) { throw new Exception("Query was cancelled."); } else if (queryState == QueryExecutionState.SUCCEEDED) { isQueryStillRunning = false; } else { // Sleep an amount of time before retrying again. Thread.Sleep(TimeSpan.FromMilliseconds(ExampleConstants.SLEEP_AMOUNT_IN_MS)); } Console.WriteLine("Current Status is: " + queryState); } }
/** * This code calls Athena and retrieves the results of a query. * The query must be in a completed state before the results can be retrieved and * paginated. The first row of results are the column headers. */ private static void processResultRows(AmazonAthenaClient athenaClient, String queryExecutionId) { GetQueryResultsRequest getQueryResultsRequest = new GetQueryResultsRequest() { // Max Results can be set but if its not set, it will choose the maximum page size // As of the writing of this code, the maximum value is 1000 // MaxResults = 1000 QueryExecutionId = queryExecutionId }; var getQueryResultsResponse = athenaClient.GetQueryResults(getQueryResultsRequest); while (true) { var results = getQueryResultsResponse.ResultSet.Rows; foreach (Row row in results) { // Process the row. The first row of the first page holds the column names. processRow(row, getQueryResultsResponse.ResultSet.ResultSetMetadata.ColumnInfo); } // If nextToken is null, there are no more pages to read. Break out of the loop. if (String.IsNullOrEmpty(getQueryResultsResponse.NextToken)) { break; } getQueryResultsRequest.NextToken = getQueryResultsResponse.NextToken; getQueryResultsResponse = athenaClient.GetQueryResults(getQueryResultsRequest); } }
private async Task <string> SubmitAthenaQuery(AmazonAthenaClient client, string theQuery, ParsedAthenaResponse niceAthenaResult) { // The QueryExecutionContext allows us to set the Database. QueryExecutionContext queryExecutionContext = new QueryExecutionContext(); queryExecutionContext.Database = Functions.DatabaseName; // The result configuration specifies where the results of the query should go in S3 and encryption options ResultConfiguration resultConfiguration = new ResultConfiguration(); resultConfiguration.OutputLocation = Functions.QueryOutputLocation; // Create the StartQueryExecutionRequest to send to Athena which will start the query. StartQueryExecutionRequest startQueryExecutionRequest = new StartQueryExecutionRequest(); startQueryExecutionRequest.QueryString = theQuery; //Now reading this dynamically niceAthenaResult.columnOrder = new List <string>(); startQueryExecutionRequest.QueryExecutionContext = queryExecutionContext; startQueryExecutionRequest.ResultConfiguration = resultConfiguration; var startQueryExecutionResponse = await client.StartQueryExecutionAsync(startQueryExecutionRequest); return(startQueryExecutionResponse.QueryExecutionId); }
private async Task WaitForQueryToComplete(AmazonAthenaClient client, string queryExecutionId) { GetQueryExecutionRequest getQueryExecutionRequest = new GetQueryExecutionRequest(); getQueryExecutionRequest.QueryExecutionId = queryExecutionId; bool isQueryStillRunning = true; while (isQueryStillRunning) { var queryExecutionResponse = await client.GetQueryExecutionAsync(getQueryExecutionRequest); QueryExecutionStatus queryStatus = queryExecutionResponse.QueryExecution.Status; if (queryStatus.State == QueryExecutionState.FAILED) { throw new Exception("Query Failed to run with Error Message: " + queryExecutionResponse.QueryExecution.Status.StateChangeReason); } else if (queryStatus.State == QueryExecutionState.CANCELLED) { throw new Exception("Query was cancelled."); } else if (queryStatus.State == QueryExecutionState.SUCCEEDED) { isQueryStillRunning = false; } // Sleep an amount before retrying again. Console.WriteLine("Current Status is: " + queryStatus.State.Value); Thread.Sleep(new TimeSpan(0, 0, 1)); } }
private async Task ProcessResultRows(AmazonAthenaClient client, string queryExecutionId, ParsedAthenaResponse niceAthenaResult) { GetQueryResultsRequest getQueryResultsRequest = new GetQueryResultsRequest(); // Max Results can be set but if its not set, // it will choose the maximum page size // As of the writing of this code, the maximum value is 1000 // .withMaxResults(1000) getQueryResultsRequest.QueryExecutionId = queryExecutionId; var getQueryResultsResponse = await client.GetQueryResultsAsync(getQueryResultsRequest); List <ColumnInfo> columnInfoList = getQueryResultsResponse.ResultSet.ResultSetMetadata.ColumnInfo; ResultSet responseData = getQueryResultsResponse.ResultSet; ReadHeadersFromColumnInfo(getQueryResultsResponse.ResultSet, niceAthenaResult); while (true) { //Convert the returned response to a serialisable JSON object ProcessRow_NameCounts(responseData, niceAthenaResult); // If the nextToken is null, there are no more pages to read. Break out of the loop. if (getQueryResultsResponse.NextToken == null) { break; } getQueryResultsResponse = await client.GetQueryResultsAsync( new GetQueryResultsRequest { NextToken = getQueryResultsResponse.NextToken }); Console.WriteLine("getting more data from response..."); } }
/** * Submits a sample query to Athena and returns the execution ID of the query. */ private static String submitAthenaQuery(AmazonAthenaClient athenaClient) { // The QueryExecutionContext allows us to set the Database. var queryExecutionContext = new QueryExecutionContext() { Database = ExampleConstants.ATHENA_DEFAULT_DATABASE }; // The result configuration specifies where the results of the query should go in S3 and encryption options var resultConfiguration = new ResultConfiguration() { // You can provide encryption options for the output that is written. // EncryptionConfiguration = encryptionConfiguration OutputLocation = ExampleConstants.ATHENA_OUTPUT_BUCKET }; // Create the StartQueryExecutionRequest to send to Athena which will start the query. var startQueryExecutionRequest = new StartQueryExecutionRequest() { QueryString = ExampleConstants.ATHENA_SAMPLE_QUERY, QueryExecutionContext = queryExecutionContext, ResultConfiguration = resultConfiguration }; var startQueryExecutionResponse = athenaClient.StartQueryExecution(startQueryExecutionRequest); return(startQueryExecutionResponse.QueryExecutionId); }
public static void Example() { // Create an Amazon Athena client var athenaConfig = new AmazonAthenaConfig { RegionEndpoint = RegionEndpoint.USEast1, Timeout = TimeSpan.FromMilliseconds(ExampleConstants.CLIENT_EXECUTION_TIMEOUT) }; var athenaClient = new AmazonAthenaClient(config: athenaConfig); String sampleQueryExecutionId = submitAthenaQuery(athenaClient); // Submit the stop query Request var stopQueryExecutionRequest = new StopQueryExecutionRequest() { QueryExecutionId = sampleQueryExecutionId }; var stopQueryExecutionResponse = athenaClient.StopQueryExecution(stopQueryExecutionRequest); // Ensure that the query was stopped var getQueryExecutionRequest = new GetQueryExecutionRequest() { QueryExecutionId = sampleQueryExecutionId }; var getQueryExecutionResponse = athenaClient.GetQueryExecution(getQueryExecutionRequest); if (getQueryExecutionResponse.QueryExecution.Status.State == QueryExecutionState.CANCELLED) { Console.WriteLine("Query has been cancelled"); } }
public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems) { AmazonAthenaConfig config = new AmazonAthenaConfig(); config.RegionEndpoint = region; ConfigureClient(config); AmazonAthenaClient client = new AmazonAthenaClient(creds, config); GetQueryResultsResponse resp = new GetQueryResultsResponse(); do { GetQueryResultsRequest req = new GetQueryResultsRequest { NextToken = resp.NextToken , MaxResults = maxItems }; resp = client.GetQueryResults(req); CheckError(resp.HttpStatusCode, "200"); foreach (var obj in resp.UpdateCount) { AddObject(obj); } foreach (var obj in resp.ResultSet) { AddObject(obj); } }while (!string.IsNullOrEmpty(resp.NextToken)); }
static void Main(string[] args) { AmazonAthenaClient client = new AmazonAthenaClient(); while (true) { using (var writer = new StreamWriter(@"C:\Users\bslocum\Desktop\AthenaRecords.csv")) { using (var csv = new CsvWriter(writer)) { Console.WriteLine("Starting"); string currentPageId = null; int count = 0; int totalRunning = 0; while (count < 1000) { var executionParams = new Amazon.Athena.Model.ListQueryExecutionsRequest(); if (count != 0) { executionParams.NextToken = currentPageId; } var thelist = client.ListQueryExecutions(executionParams); var theExecutions = client.BatchGetQueryExecution(new Amazon.Athena.Model.BatchGetQueryExecutionRequest() { QueryExecutionIds = thelist.QueryExecutionIds }); currentPageId = thelist.NextToken; var theRunners = theExecutions.QueryExecutions.Where(x => x.Status.State == QueryExecutionState.RUNNING); foreach (var aRunner in theRunners) { Console.WriteLine($"Time: {aRunner.Status.SubmissionDateTime.ToLocalTime().ToLongTimeString()}, {aRunner.ResultConfiguration.OutputLocation}, {aRunner.StatementType}"); var queryLine = new QueryRun(); queryLine.Time = aRunner.Status.SubmissionDateTime.ToLocalTime().ToLongTimeString(); queryLine.OutPutLocation = aRunner.ResultConfiguration.OutputLocation; queryLine.StatementType = aRunner.StatementType; csv.WriteRecord(queryLine); csv.Flush(); } totalRunning += theRunners.Count(); count += 50; } Console.WriteLine($"Finished with {totalRunning} running"); Console.WriteLine($"Sleeping for 1 min"); Console.WriteLine("----------------------------------------------------"); Console.WriteLine(""); System.Threading.Thread.Sleep(15000); } } } Console.ReadKey(); }
public void ExecuteQuery(string sql) { var awsCredentials = new Amazon.Runtime.BasicAWSCredentials("A", "B"); var c = new AmazonAthenaClient(awsCredentials); QueryExecutionContext queryExecutionContext = new QueryExecutionContext(); queryExecutionContext.Database = ATHENA_DEFAULT_DATABASE; // The result configuration specifies where the results of the query should go in S3 and encryption options ResultConfiguration resultConfiguration = new ResultConfiguration(); // You can provide encryption options for the output that is written. // .withEncryptionConfiguration(encryptionConfiguration) resultConfiguration.OutputLocation = ATHENA_OUTPUT_BUCKET; // Create the StartQueryExecutionRequest to send to Athena which will start the query. StartQueryExecutionRequest startQueryExecutionRequest = new StartQueryExecutionRequest(); startQueryExecutionRequest.QueryString = sql; startQueryExecutionRequest.QueryExecutionContext = queryExecutionContext; startQueryExecutionRequest.ResultConfiguration = resultConfiguration; var startQueryExecutionResponse = c.StartQueryExecutionAsync(startQueryExecutionRequest); //Console.WriteLine($"Query ID {startQueryExecutionResponse.QueryExecutionId}"); // return startQueryExecutionResponse.QueryExecutionId(); }
/// <summary> /// Provide last 500 records of COVID-19 status and progress in USA /// </summary> /// <returns>List of COVID-19' numbers of testing, positive, negative, and death </returns> public async Task <IEnumerable <CovidTestingStatesDaily> > ProgressAsync() { var queryString = $@"{baseQuery} ORDER BY sta.date DESC, sta.state ASC LIMIT 500"; return(await AmazonAthenaClient.QueryAsync <CovidTestingStatesDaily>(queryString)); }
/// <summary> /// provide support for resolving AthenaAPI from AWS environment /// </summary> /// <param name="sessionAWSCredentials"></param> public AWSAthenaAPI(SessionAWSCredentials sessionAWSCredentials) { this.sessionAWSCredentials = sessionAWSCredentials; var credentials = sessionAWSCredentials.GetCredentials(); basicAWSCredentials = new BasicAWSCredentials(credentials.AccessKey, credentials.SecretKey); amazonAthenaClient = new AmazonAthenaClient(sessionAWSCredentials); DefaultOutputLocation = Environment.GetEnvironmentVariable("AWSAthenaDefaultOutputLocation"); }
private AmazonAthenaClient CreateAthenaClient() { AmazonAthenaClient athenaClient = new AmazonAthenaClient(Functions.AwsAccessKeyId, Functions.AwsSecretAccessKey, Functions.DatabaseName); AmazonAthenaConfig config = new AmazonAthenaConfig(); config.Timeout = new TimeSpan(0, 0, 30); return(athenaClient); }
/// <summary> /// Provide COVID-19 status and progress by a given date /// </summary> /// <param name="date">date to filter</param> /// <returns>List of COVID-19' numbers of testing, positive, negative, and death </returns> public Task <string> ProgressAsync(DateTime date) { // '{date:yyyyMMdd}' is a simplified code of date.ToString("yyyyMMdd") var queryString = $@"{baseQuery} WHERE sta.date ='{date:yyyyMMdd}' ORDER BY sta.state"; return(AmazonAthenaClient.QueryAndGoAsync(queryString)); }
// This code shows how to create and configure an Amazon Athena client. public static void Example() { // Create an Amazon Athena client var athenaConfig = new AmazonAthenaConfig { RegionEndpoint = RegionEndpoint.USEast1, Timeout = TimeSpan.FromMilliseconds(ExampleConstants.CLIENT_EXECUTION_TIMEOUT) }; var athenaClient = new AmazonAthenaClient(config: athenaConfig); }
public BaseRepository() { //Option 1: Use the default credential provider chain (recommended) // to learn more check: https://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/net-dg-config-creds.html AmazonAthenaClient = new AmazonAthenaClient(RegionEndpoint.USWest2); //Option 2: Hardcode //Uncomment if you prefer hardcode your Access key and Secret access instead of using the environment variable //AmazonAthenaClient = new AmazonAthenaClient("YOUR_AWS_ACCESS_KEY", "YOUR_AWS_SECRET_ACCESS", RegionEndpoint.USWest2); }
static void Main(string[] args) { using (var client = new AmazonAthenaClient(Amazon.RegionEndpoint.USEast1)) { QueryExecutionContext qContext = new QueryExecutionContext(); qContext.Database = ATHENA_DB; ResultConfiguration resConf = new ResultConfiguration(); resConf.OutputLocation = ATHENA_TEMP_PATH; Console.WriteLine("Created Athena Client"); run(client, qContext, resConf).Wait(); } }
private async Task <List <Dictionary <String, String> > > queryAthena(String date) { using (var athenaClient = new AmazonAthenaClient(Amazon.RegionEndpoint.USEast2)) { QueryExecutionContext qContext = new QueryExecutionContext(); qContext.Database = ATHENA_DB; ResultConfiguration resConf = new ResultConfiguration(); resConf.OutputLocation = ATHENA_TEMP_PATH; List <Dictionary <String, String> > items = await runQuery(athenaClient, qContext, resConf, date); return(items); } }
static async Task Main(string[] args) { var athenaClient = new AmazonAthenaClient(new AmazonAthenaConfig { RegionEndpoint = RegionEndpoint.EUWest1 }); var method1 = new Method1(athenaClient); await method1.Execute(); var method2 = new Method2(athenaClient); await method2.Execute(); }
public static async Task <JRaw> QueryAthenaAndSend(string datestring) { using (var client = new AmazonAthenaClient(Amazon.RegionEndpoint.USEast2)) { QueryExecutionContext qContext = new QueryExecutionContext(); qContext.Database = ATHENA_DB; ResultConfiguration resConf = new ResultConfiguration(); resConf.OutputLocation = ATHENA_TEMP_PATH; Console.WriteLine("Created Athena Client"); List <Dictionary <String, String> > items = await Run(client, qContext, resConf, datestring); if (items.Count == 1 && items[0].ContainsKey("error")) { items[0].TryGetValue("error", out string errorinfo); return(new JRaw(errorinfo)); } // return items.ToString(); JObject obj = new JObject(); if (items.Count == 0) { obj.Add("count", "zero"); return(obj.ToObject <JRaw>()); } obj.Add("count", items.Count); for (int i = 1; i < items.Count; i++) { JProperty nameProp = null; JProperty idProp = null; foreach (KeyValuePair <String, String> pair in items[i]) { if (pair.Key == "emp_name") { nameProp = new JProperty("name", pair.Value); } if (pair.Key == "emp_id") { idProp = new JProperty("id", pair.Value); } } if (nameProp != null && idProp != null) { obj.Add("emp " + i, new JObject(nameProp, idProp)); } else { return(null); } } return(obj.ToObject <JRaw>()); } }
protected IAmazonAthena CreateClient(AWSCredentials credentials, RegionEndpoint region) { var config = new AmazonAthenaConfig { RegionEndpoint = region }; Amazon.PowerShell.Utils.Common.PopulateConfig(this, config); this.CustomizeClientConfig(config); var client = new AmazonAthenaClient(credentials, config); client.BeforeRequestEvent += RequestEventHandler; client.AfterResponseEvent += ResponseEventHandler; return(client); }
public static async Task <GetQueryResultsResponse> QueryAsyncLight(this AmazonAthenaClient client, StartQueryExecutionRequest request, int timeoutSeconds) { var executionResult = await client.StartQueryExecutionAsync(request); var queryExecutionRequest = new GetQueryExecutionRequest { QueryExecutionId = executionResult.QueryExecutionId }; return(await Task.Run <GetQueryResultsResponse>(async() => { var start = DateTime.Now; while ((DateTime.Now - start).Seconds < timeoutSeconds) { await Task.Delay(1000); var response = await client.GetQueryExecutionAsync(queryExecutionRequest); switch (response.QueryExecution.Status.State) { case var queued when queued == QueryExecutionState.QUEUED: case var running when running == QueryExecutionState.RUNNING: continue; case var cancelled when cancelled == QueryExecutionState.CANCELLED: { throw new AthenaQueryExecutionException($"The query({executionResult.QueryExecutionId}) has been calceled", response); } case var failed when failed == QueryExecutionState.FAILED: { throw new AthenaQueryExecutionException($"The query({executionResult.QueryExecutionId}) failed", response); } case var secceeded when secceeded == QueryExecutionState.SUCCEEDED: { var resultRequest = new GetQueryResultsRequest { QueryExecutionId = executionResult.QueryExecutionId }; var result = await client.GetQueryResultsAsync(resultRequest); return result; } default: throw new AthenaQueryExecutionException($"Unrecognized query({response.QueryExecution.QueryExecutionId}) State", response); } } throw new AthenaQueryExecutionException($"query({executionResult.QueryExecutionId}) Timeout", null); })); }
public async Task <string> FunctionHandler(ILambdaContext context) { string strResult = ""; using (var client = new AmazonAthenaClient(Amazon.RegionEndpoint.APSouth1)) { QueryExecutionContext qContext = new QueryExecutionContext(); qContext.Database = ATHENA_DB; ResultConfiguration resConf = new ResultConfiguration(); resConf.OutputLocation = ATHENA_TEMP_PATH; strResult = await run(client, qContext, resConf); } return(strResult); }
public static void Example() { // Create an Amazon Athena client var athenaConfig = new AmazonAthenaConfig { RegionEndpoint = RegionEndpoint.USEast1, Timeout = TimeSpan.FromMilliseconds(ExampleConstants.CLIENT_EXECUTION_TIMEOUT) }; var athenaClient = new AmazonAthenaClient(config: athenaConfig); String queryExecutionId = submitAthenaQuery(athenaClient); waitForQueryToComplete(athenaClient, queryExecutionId); processResultRows(athenaClient, queryExecutionId); }
private static String getNamedQueryId(AmazonAthenaClient athenaClient) { // Create the NameQuery Request. CreateNamedQueryRequest createNamedQueryRequest = new CreateNamedQueryRequest() { Database = ExampleConstants.ATHENA_DEFAULT_DATABASE, QueryString = ExampleConstants.ATHENA_SAMPLE_QUERY, Name = "SampleQueryName", Description = "Sample Description" }; // Create the named query. If it fails, an exception is thrown. var createNamedQueryResponse = athenaClient.CreateNamedQuery(createNamedQueryRequest); return(createNamedQueryResponse.NamedQueryId); }
public static async Task AWSAthenaSearchByDescription(string searchkey) { using (var client = new AmazonAthenaClient(AWS_ACCESS_KEY, AWS_SECRET_KEY, Amazon.RegionEndpoint.USEast2)) { QueryExecutionContext qContext = new QueryExecutionContext(); qContext.Database = "bookdb"; ResultConfiguration resConf = new ResultConfiguration(); resConf.OutputLocation = "s3://test-bucket-kalam/"; Console.WriteLine("Created Athena Client"); /* Execute a simple query on a table */ StartQueryExecutionRequest qReq = new StartQueryExecutionRequest() { QueryString = "SELECT * FROM book where bookdescription like '%" + searchkey + "%'", QueryExecutionContext = qContext, ResultConfiguration = resConf }; try { /* Executes the query in an async manner */ StartQueryExecutionResponse qRes = await client.StartQueryExecutionAsync(qReq); /* Call internal method to parse the results and return a list of key/value dictionaries */ List <Dictionary <String, String> > items = await getQueryExecution(client, qRes.QueryExecutionId); foreach (var item in items) { foreach (KeyValuePair <String, String> pair in item) { Console.WriteLine("Col: {0}", pair.Key); Console.WriteLine("Val: {0}", pair.Value); } } } catch (InvalidRequestException e) { Console.WriteLine("Run Error: {0}", e.Message); } } }
public static void Example() { // Create an Amazon Athena client var athenaConfig = new AmazonAthenaConfig { RegionEndpoint = RegionEndpoint.USEast1, Timeout = TimeSpan.FromMilliseconds(ExampleConstants.CLIENT_EXECUTION_TIMEOUT) }; var athenaClient = new AmazonAthenaClient(config: athenaConfig); String sampleNamedQueryId = getNamedQueryId(athenaClient); // Create the delete named query request var deleteNamedQueryRequest = new DeleteNamedQueryRequest() { NamedQueryId = sampleNamedQueryId }; // Delete the named query var deleteNamedQueryResponse = athenaClient.DeleteNamedQuery(deleteNamedQueryRequest); }
public static void Example() { // Create an Amazon Athena client var athenaConfig = new AmazonAthenaConfig { RegionEndpoint = RegionEndpoint.USEast1, Timeout = TimeSpan.FromMilliseconds(ExampleConstants.CLIENT_EXECUTION_TIMEOUT) }; var athenaClient = new AmazonAthenaClient(config: athenaConfig); // Create the named query request. var createNamedQueryRequest = new CreateNamedQueryRequest() { Database = ExampleConstants.ATHENA_DEFAULT_DATABASE, QueryString = ExampleConstants.ATHENA_SAMPLE_QUERY, Description = "Sample Description", Name = "SampleQuery2", }; // Call Athena to create the named query. If it fails, an exception is thrown. var createNamedQueryResponse = athenaClient.CreateNamedQuery(createNamedQueryRequest); }