In this blog post, I’ll walk you through a way to connect to your Amazon Athena with Exploratory using Amazon Athena Data Source.
Before you get started, please make sure to attach required permissions to your AWS account. (Or ask Admin person to do so)
Make sure to assign below permissions.
Please follow this note to install unixODBC.
First, please download Amazon Athena ODBC Driver, then install it.
Below is an example for MacOS.
/Library/simba/athenaodbc/lib/simba.athenaodbc.ini
ODBCInstLib=/usr/local/lib/libodbcinst.dylib
Please follow the steps to check if the ODBC driver is properly registered to unixODBC.
➜ odbcinst -j
unixODBC 2.3.9
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/hidetakakojima/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
Check if you can see below entry for Athena ODBC Driver.
[Simba Athena ODBC Driver]
Driver=/Library/simba/athenaodbc/lib/libathenaodbc_sb64.dylib
If you don't see this entry, please add the entry to the file then save it.
Click the down arrow button next to Project Name.
Click the Add Button.
Select Amazon Athena under "Database" tab.
On the dialog, enter Connection Name, AWS Region, S3 Output Location, User name, and Password.
Enter a name for your Amazon Athena Connection
Use the default value (i.e. Simba Athena ODBC Driver)
This is your Amazon Athena Region (e.g. us-west-2)
This is the path that output is saved. Please replace it with your path that you have write permission. (e.g. aws-athena-query-results-xxxxxxxxxxx-us-west-2 xxxxxxxxxxx varies)
This is an optional parameter. When you are accessing from inside the Virtual Private Cloud (VPC), you can connect to Athena via VPC endpoint instead of connecting over the Internet.
To get the VPC Endpoint information, access to your VPC dashboard with a browser, then click the "Endpoints" link and check the DNS names.
Also, make sure to open port 443 and 444 for Inbound Rules of the Security Group associated with the VPC endpoint used for connecting to Athena.
If you do not enable private DNS hostnames, Amazon VPC provides a DNS endpoint name that you can use in the following format. (Make sure to replace VPC_Endpoint_ID with your actual ID)
VPC_Endpoint_ID.athena.Region.vpce.amazonaws.com
Please refer Connect to Amazon Athena Using an Interface VPC Endpoint for details.
Since we use IAM Credential for this example, you need to pass your aws access key id.
Since we use IAM Credential for this example, you need to pass your secret access key.
This is an optional parameter. You can set workgroup to Control Query Access
Then Click Test Connection and make sure it connects successfully.
Click Add to save the connection.
If you setup HTTP Proxy on System Configuration Dialog,
This HTTP proxy information is automatically applied to your Amazon Athena connection.
Click Plus button next to Data Frames and select Database Data
Then select Athena.
Select AWS Athena from Connection pull down list. Then you can see schema information on your left-hand side tree and can write a SQL query. In this example, it queries from a elb_logs table of sampledb database.
select * from sampledb.elb_logs
where request_verb = 'GET'
and backend_port = 80
Once it’s imported by clicking Save button, you can start analyzing the data!
When you try to connect to Amazon Athena from your Mac, you might see the below error and cannot connect to Athena.
Error : nanodbc/nanodbc.cpp:1021: 00000: [unixODBC][Driver Manager]Can't open lib 'Simba Athena ODBC Driver' : file not found
if you hit this issue, please follow the below steps.
Below is an example.
➜ odbcinst -j
unixODBC 2.3.9
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/hidetakakojima/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
Check if you can see below entry for Athena ODBC Driver.
[Simba Athena ODBC Driver]
Driver=/Library/simba/athenaodbc/lib/libathenaodbc_sb64.dylib