我正在尝试使用c#athena驱动程序执行athena查询。
Amazon.Athena.Model.ResultConfiguration resultConfig = new Amazon.Athena.Model.ResultConfiguration();
resultConfig.OutputLocation = "https://s3.us-east-2.amazonaws.com/testbucket/one/2018-02-06/";
//other inputs i have tried
//"s3://testbucket/one/2018-02-06/"
//testbucket
//Populate the request object
Amazon.Athena.Model.StartQueryExecutionRequest queryExec = new Amazon.Athena.Model.StartQueryExecutionRequest();
queryExec.QueryString = query.QueryString;
queryExec.QueryExecutionContext = queryExecutionContext;
queryExec.ResultConfiguration = resultConfig;
StartQueryExecutionResponse athenaResponse = athenaClient.StartQueryExecution(queryExec);//throws exception
不同案例的例外情况:
outputLocation不是有效的S3路径。提供https://s3.us-east-2.amazonaws.com/testbucket/one/2018-02-06/
无法验证/创建输出存储桶testbucket。提供s3:// testbucket / one / 2018-02-06 /
- 醇>
无法验证/创建输出存储桶testbucket。提供了testbucket
有人可以用正确的s3格式帮助我吗?
提前致谢。
答案 0 :(得分:1)
输出位置需要采用以下格式:
s3://{bucketname}/{path}
在您的情况下,这将导致以下位置:
resultConfig.OutputLocation = "s3://testbucket/one/2018-02-06/";
答案 1 :(得分:0)
Amazon.Athena.AmazonAthenaClient _client = new Amazon.Athena.AmazonAthenaClient(AwsAccessKeyId, AwsSecretAccessKey, EndPoint);
Amazon.Athena.Model.ResultConfiguration resultConfig = new Amazon.Athena.Model.ResultConfiguration();
resultConfig.OutputLocation = "s3://"+BucketName+"/key1/";
string query = "SELECT * FROM copalanadev.logs";
//Populate the request object
Amazon.Athena.Model.StartQueryExecutionRequest queryExec = new Amazon.Athena.Model.StartQueryExecutionRequest();
queryExec.QueryString = query;
//queryExec.QueryExecutionContext = queryExecutionContext;
queryExec.ResultConfiguration = resultConfig;
StartQueryExecutionResponse athenaResponse = _client.StartQueryExecution(queryExec);//throws exception