ToolJet/docs/versioned_docs/version-3.16.0-LTS/data-sources/athena.md

84 lines
2.8 KiB
Markdown
Raw Normal View History

2025-08-04 06:49:49 +00:00
---
id: athena
title: Athena
---
ToolJet can connect to **Amazon Athena** which is an interactive query service that makes it easy to analyze data in Amazon S3 using standard SQL.
## Connection
To establish a connection with the **Amazon Athena** data source, you can either click on the **+ Add new Data source** button located on the query panel or navigate to the **[Data Sources](/docs/data-sources/overview)** page from the ToolJet dashboard and choose **Amazon Athena** as the data source.
ToolJet requires the following to connect to your Athena.
- **Database**
- **S3 output location**
- **Access key**
- **Secret key**
- **Region**
:::info
You can also configure for **[additional optional parameters](https://github.com/ghdna/athena-express)**.
:::
<img className="screenshot-full img-full" src="/img/datasource-reference/athena/athena-connection-v3.png" alt="Athena connection" />
2025-08-04 06:49:49 +00:00
## Querying Amazon Athena
1. Click on **+ Add** button of the query manager at the bottom panel of the editor.
2. Select the **Amazon Athena** datasource added in previous step.
3. Select the SQL Query from the dropdown and enter the query.
4. Click on the **Preview** button to preview the output or Click on the **Run** button to trigger the query.
:::tip
2026-02-11 06:30:57 +00:00
Refer [Amazon Athena documentation](https://docs.aws.amazon.com/athena/latest/ug/what-is.html) for more information.
2025-08-04 06:49:49 +00:00
:::
<img style={{ marginBottom:'15px' }} className="screenshot-full img-full" src="/img/datasource-reference/athena/athena-query-v3.png" alt="Athena Query" />
2025-08-04 06:49:49 +00:00
2026-02-11 06:30:57 +00:00
## SQL Query Examples
2025-08-04 06:49:49 +00:00
### Creating Table
This query is used to create an external table within the database. The data for this table is stored in an S3 bucket at the provided URL (`s3://athena-express-akiatfa53s-2026/` in this example).
2025-08-04 06:49:49 +00:00
```sql
CREATE EXTERNAL TABLE student (
name STRING,
age INT
) LOCATION 's3://athena-express-akiatfa53s-2026/';
2025-08-04 06:49:49 +00:00
```
2026-02-11 06:30:57 +00:00
<img className="screenshot-full img-full" src="/img/datasource-reference/athena/athena-create.png" alt="Athena connection" />
2025-08-04 06:49:49 +00:00
### Inserting to Table
This query is attempting to insert a new record into the *student* table in a database.
```sql
INSERT INTO student
VALUES ('Lansing',1)
```
2026-02-11 06:30:57 +00:00
<img className="screenshot-full img-full" src="/img/datasource-reference/athena/athena-insert.png" alt="Athena connection" />
2025-08-04 06:49:49 +00:00
### Select Operation
This query retrieves all records from the *student* table where the age of the student is exactly 1 year.
```sql
SELECT * from student WHERE AGE=1
```
2026-02-11 06:30:57 +00:00
<img className="screenshot-full img-full" src="/img/datasource-reference/athena/athena-select.png" alt="Athena connection" />
2025-08-04 06:49:49 +00:00
### List Tables
This query is used to display a list of all tables in the current database.
```sql
SHOW TABLES
```
<img className="screenshot-full img-full" src="/img/datasource-reference/athena/athena-list.png" alt="Athena connection" />