1

我正在尝试使用 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

不同情况的例外:

  1. outputLocation 不是有效的 S3 路径。提供https://s3.us-east-2.amazonaws.com/testbucket/one/2018-02-06/

  2. 无法验证/创建输出存储桶 testbucket。提供 s3://testbucket/one/2018-02-06/

  3. 无法验证/创建输出存储桶 testbucket。提供测试桶

有人可以帮助我使用正确的 s3 格式吗?

提前致谢。

4

2 回答 2

3

输出位置需要采用以下格式:

s3://{bucketname}/{path}

在您的情况下,这将导致以下位置:

resultConfig.OutputLocation = "s3://testbucket/one/2018-02-06/";
于 2018-02-14T07:21:46.827 回答
1
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
于 2018-08-20T11:46:25.280 回答