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

Updated additional Athena RStudio ODBC steps #510

Merged
merged 1 commit into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 68 additions & 1 deletion docs/athena/RStudio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ This uses [R-DBI library](https://dbi.r-dbi.org) through ODBC connection to Athe

```
aws sso login --profile prodops
yawsso -p prodops
```

### Step 3
Expand Down Expand Up @@ -46,24 +47,90 @@ con <- DBI::dbConnect(
select count(1) from "AwsDataCatalog"."multiqc"."dragen_umccrise";
```

- You can also use more programmatic way with R through `glue` or `dbplyr` then `ggplot2`. See [3] for more details.
- You can also use more programmatic way with R through `glue` or `dbplyr` then `ggplot2`.

- See [3] for more details.


## MacOS

> If you are on macOS, you may need the following additional steps.

- Update Simba ODBC config file to match as follows.

```
sudo vi /Library/simba/athenaodbc/lib/simba.athenaodbc.ini
```

```
[Driver]
## - Note that this default DriverManagerEncoding of UTF-32 is for iODBC.
ErrorMessagesPath=/Library/simba/athenaodbc/ErrorMessages
LogLevel=0
LogPath=
SwapFilePath=/tmp
Driver=/Library/simba/athenaodbc/lib/libathenaodbc_sb64.dylib
ODBCInstLib=/usr/local/lib/libodbcinst.dylib
```

- Install [unixODBC](http://www.unixodbc.org)

```
brew install unixodbc
```

- List unixODBC config file locations

```
odbcinst -j

unixODBC 2.3.11
DRIVERS............: /usr/local/etc/odbcinst.ini
SYSTEM DATA SOURCES: /usr/local/etc/odbc.ini
FILE DATA SOURCES..: /usr/local/etc/ODBCDataSources
USER DATA SOURCES..: /Users/<username>/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
```

- Update unixODBC config file to match as follows.

```
vi /usr/local/etc/odbcinst.ini
```

```
[Simba Athena ODBC Driver]
Driver=/Library/simba/athenaodbc/lib/libathenaodbc_sb64.dylib
```

- See [4] [5] for additional resources.

## Starter Demo

### Scripts

- [athena.R](athena.R)
- [athena.sql](athena.sql)
- [athena_federated_query.sql](athena_federated_query.sql)

### Windows

![rstudio_dbi_odbc_athena_1.png](rstudio_dbi_odbc_athena_1.png)

![rstudio_dbi_odbc_athena_2.png](rstudio_dbi_odbc_athena_2.png)

![rstudio_dbi_odbc_athena_federated_query.png](rstudio_dbi_odbc_athena_federated_query.png)

### MacOS

![rstudio_dbi_odbc_athena_macOS.png](rstudio_dbi_odbc_athena_macOS.png)

## REF

* [1] https://docs.aws.amazon.com/athena/latest/ug/connect-with-odbc.html
* [2] https://solutions.rstudio.com/db/databases/athena/
* [3] https://www.rstudio.com/blog/working-with-databases-and-sql-in-rstudio/
* [4] https://exploratory.io/note/exploratory/How-to-use-Amazon-Athena-ODBC-Driver-on-Mac-UtO9zcN7
* [5] https://github.com/r-dbi/odbc
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.