gpt4 book ai didi

r - "The requested fetchSize is more than the allowed value in Athena"带有 JDBC 驱动程序

转载 作者:行者123 更新时间:2023-12-04 22:56:20 26 4
gpt4 key购买 nike

我正在尝试使用 RJDBC 将数据从 Athena DB 提取到 R 中如 AWS's own blog 上的详细描述.唉,我试图提取的数据量很大,所以我收到以下错误消息:

Error in .jcall(rp, "I", "fetch", stride, block) : 
java.sql.SQLException: The requested fetchSize is more than the allowed value in Athena. Please reduce the fetchSize and try again. Refer to the Athena documentation for valid fetchSize values.

雅典娜文档实际上并没有给出任何这样的 fetchSize值,但我从 this github issue 收集该值应低于 1000。我从同一个 github 问题中收集到,无法通过此 fetchSize到 RJDBC。那么是否有其他方式来查询符合此限制的 Athena?

最佳答案

基本问题是dbGetQuery不允许指定 fetchSize .如 per the RJDBC package author一种解决方法是调用 dbGetQuery 的两个函数单独包装并通过fetchSizefetch() :

q <- dbSendQuery(c, ...)
fetch(q, -1, block=999)

更普遍:
setMethod("dbGetQuery", signature(conn="JDBCConnection", statement="character"),  def=function(conn, statement, ...) {
r <- dbSendQuery(conn, statement, ...)
on.exit(.jcall(r@stat, "V", "close"))
if (conn@jc %instanceof% "com.amazonaws.athena.jdbc.AthenaConnection") fetch(r, -1, 999) # Athena can only pull 999 rows at a time
else fetch(r, -1)
})

关于r - "The requested fetchSize is more than the allowed value in Athena"带有 JDBC 驱动程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44379318/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com