Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pass-through block parameter from dbGetQuery() to fetch() #44

Closed
MegaByte opened this issue Apr 28, 2017 · 5 comments
Closed

pass-through block parameter from dbGetQuery() to fetch() #44

MegaByte opened this issue Apr 28, 2017 · 5 comments

Comments

@MegaByte
Copy link

MegaByte commented Apr 28, 2017

The Amazon Athena driver (http://docs.aws.amazon.com/athena/latest/ug/connect-with-jdbc.html) fails with

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.

RJDBC sets a fetch block size of 2048 by default (https://github.com/s-u/RJDBC/blob/master/R/class.R#L306) but Amazon Athena wants the size to be <= 999 (this number is not actually documented).

@RoyalTS
Copy link

RoyalTS commented Jun 5, 2017

Is there any way one can override the default and set the fetchSize to a lower level?

@MegaByte
Copy link
Author

MegaByte commented Jun 5, 2017

I did this as a temporary workaround (since I am using multiple databases at once):

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)
})

@s-u
Copy link
Owner

s-u commented Jun 6, 2017

Right, you can simply use

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

dbGetQuery is just a convenience to call dbSendQuery followed by fetch

I guess the issue here is that we could pass-through the block parameter from dbGetQuery() to fetch()

@s-u s-u changed the title Amazon Athena queries fail due to block size restrictions pass-through block parameter from dbGetQuery() to fetch() Jun 6, 2017
@RoyalTS
Copy link

RoyalTS commented Jun 6, 2017

The workaround works, thanks!

But yeah, it'd be great if dbGetQuery would pass this through or if one could set this as an option more globally?

@nfultz
Copy link

nfultz commented Nov 7, 2017

This is fixed in AWR.Athena for whatever it's worth.

@s-u s-u closed this as completed in 10e6879 Feb 28, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants