DyfanJones / noctua

Connect R to Athena using paws SDK (DBI Interface)
https://dyfanjones.github.io/noctua/
Other
45 stars 5 forks source link

dbGetQuery unavailable for noctua::athena #102

Closed chrissuh17 closed 4 years ago

chrissuh17 commented 4 years ago

Hello Dyfan,

I raised this question on stackoverflow.com as @datascientist2117; thank you for your response.

Here is the code I currently have.

library(tidyverse)
library(dplyr)
library(dbplyr)
library(odbc)
library(DBI)
library(RAthena)
library(rJava)

odbcListDrivers()
sort((unique(odbcListDrivers()[[1]])))

con <- DBI::dbConnect(
  odbc::odbc(),
  Driver             = "[Simba Athena ODBC Driver]",
  S3OutputLocation   = "[s3://bucket-folder/]",
  AwsRegion          = "[region]",
  AuthenticationType = "IAM Credentials",
  Schema             = "[schema]",
  UID                = rstudioapi::askForPassword("AWS Access Key"),
  PWD                = rstudioapi::askForPassword("AWS Secret Key"))

All code above is exactly the same except for the omitted values in S3OutPutLocation, AwsRegion, and Schema.

I am currently using Simba Athena ODBC Driver Version 1.1.2

I hope this information is sufficient; please let me know if there is anything else I can provide!

DyfanJones commented 4 years ago

Hi @chrissuh17 perfect :) I know the issue now :D Both RAthena and noctua create the class AthenaConnection however they work slightly differently under the hood. RAthena uses python's boto3 and noctua uses R's paws.

So what is happening is R is getting confused what class to use. So if you remove RAthena from your loaded packages noctua should work for example:

library(DBI)

# using aws/credentials file to store credentials, modify this if needed
con <- dbConnect(noctua::athena())

dbGetQuery(con, "select * from some_tbl")

Please give the above code (with your own table) a try in a new R session and tell me if it resolves the issue :)

chrissuh17 commented 4 years ago

It's working now! Thank you very much for your help.

DyfanJones commented 4 years ago

Happy to help, I hope you enjoy using the package. Please feel free to raise any feature requests :)

Will close this ticket now :)