【发布时间】:2021-08-14 03:26:51
【问题描述】:
我一直在尝试通过 paws 包从 Athena 获取数据到 R 中。到目前为止,我已经成功地让查询运行并返回了一些结果。但我得到的默认最大值为 1000。我已经看到了一些 Python 中 Boto3 库的解决方案,但即使语法相似,我也可以调用像 Boto3 那样的分页函数。
有人知道如何进行分页,或者如何使用函数的下一个标记参数吗?
这是我的代码的样子:
用于连接 AWS 服务的 SDK
install.packages('paws')
install.packages('tidyverse')
创建一个 Athena 对象:
athena <- paws::athena()
编写查询并指定输出位置:
query <- athena$start_query_execution(QueryString = '
SELECT *
FROM db.table
LIMIT 100000
',
ResultConfiguration = list(OutputLocation =
"s3://aws-athena..."
)
)
执行查询
result <- athena$get_query_execution(QueryExecutionId = query$QueryExecutionId)
获取查询输出:
output <- athena$get_query_results(QueryExecutionId = query$QueryExecutionId)
解析成表格对象
data <- dplyr::as_tibble(t(matrix(unlist(output$ResultSet$Rows),nrow = length(unlist(output$ResultSet$Rows[1])))))
colnames(data) <- as.character(unlist(data[1, ]))
data <- data[-1, ]
【问题讨论】:
标签: r amazon-web-services aws-sdk amazon-athena