我有以下代码片段。
#include <aws/core/Aws.h>
#include <aws/core/utils/logging/LogLevel.h>
#include <aws/s3/S3Client.h>
#include <aws/s3/S3Errors.h>
#include <aws/s3/model/SelectObjectContentRequest.h>
#include <aws/s3/model/InputSerialization.h>
#include <aws/s3/model/ExpressionType.h>
#include <aws/s3/model/ParquetInput.h>
#include <iostream>
using namespace Aws;
int main()
{
//The Aws::SDKOptions struct contains SDK configuration options.
//An instance of Aws::SDKOptions is passed to the Aws::InitAPI and
//Aws::ShutdownAPI methods. The same instance should be sent to both methods.
SDKOptions options;
options.loggingOptions.logLevel = Utils::Logging::LogLevel::Trace;
Aws::InitAPI(options);
Aws::Client::ClientConfiguration cfg;
Aws::String region = "eu-west-1";
cfg.region = region;
S3::S3Client client(cfg,
Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never,
false);
S3::Model::SelectObjectContentRequest request;
request.SetBucket("my-bucket");
request.SetKey("parquet_file.parquet");
request.SetExpressionType(S3::Model::ExpressionType::SQL);
request.SetExpression("SELECT * FROM s3object s LIMIT 5");
S3::Model::InputSerialization inputSerialization;
S3::Model::ParquetInput parquetInput;
inputSerialization.SetParquet(parquetInput);
request.SetInputSerialization(inputSerialization);
S3::Model::OutputSerialization outputSerialization;
S3::Model::CSVOutput csvOutput;
outputSerialization.SetCSV(csvOutput);
request.SetOutputSerialization(outputSerialization);
auto s3_select_outcome =
client.SelectObjectContent(request);
if (s3_select_outcome.IsSuccess()) {
std::cout << "Success" << std::endl;
}
else {
std::cout << "Failed with error: " << s3_select_outcome.GetError() << std::endl;
}
//Before the application terminates, the SDK must be shut down.
ShutdownAPI(options);
return 0;
}
然而,正如这里所见,结果是 type Model::SelectObjectContentOutcome
。通过遵循此处的文档,这包括一个Aws::NoResult
,虽然有一个GetResult
方法,但没有实际的方法来获取或解析结果。程序返回Success
意味着请求实际上应该返回一些东西。有谁知道如何做到这一点?谢谢!