> ## Documentation Index
> Fetch the complete documentation index at: https://docs.upsolve.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Amazon Athena

> Learn how to connect Amazon Athena to Upsolve to query your S3 data lake directly from your dashboards.

This article guides you through the process of connecting Amazon Athena to Upsolve, allowing you to query your S3 data lake within the Upsolve platform.

Athena is serverless — there is no cluster or host to provision. Instead of a network endpoint and database login, you connect with an AWS IAM key pair and tell Athena where to stage its results in S3.

## Prerequisites

Before you start, you will need the following from AWS:

* **Region** — where your Athena workgroup and Glue catalog live (e.g. `us-east-1`)
* **Access Key ID** and **Secret Access Key** — for an IAM user or service account
* **S3 output location** — an S3 URI Athena writes query results to (e.g. `s3://my-bucket/athena-results/`)
* **Database** — the Glue database holding the tables you want to query
* **Data catalog** (optional, defaults to `AwsDataCatalog`)
* **Workgroup** (optional, defaults to `primary`)

<Note>
  Athena has no username or password. The IAM key pair is the equivalent — the
  official Athena JDBC driver maps the Access Key ID to `User` and the Secret
  Access Key to `Password`, and Upsolve follows the same convention.
</Note>

Follow the steps below to obtain them:

1. Go to the AWS Management Console and open **Athena**. Confirm the region shown in the top-right corner — this is the region you will enter in Upsolve.
2. Under **Query editor → Settings**, check the **Location of query result**. If it is blank, set it to an S3 prefix you control. This is your S3 output location.
3. In **Data sources**, note the data catalog (usually `AwsDataCatalog`) and the database containing your tables. If your tables are not yet catalogued, run an AWS Glue crawler over your S3 data first.
4. Open **IAM** and create (or reuse) a user for Upsolve, then create an access key for it. Save the secret when it is shown — AWS will not display it again.

### IAM permissions

Attach a policy granting the Upsolve key pair at least:

* `athena:StartQueryExecution`, `athena:GetQueryExecution`, `athena:GetQueryResults`
* `glue:GetDatabase`, `glue:GetDatabases`, `glue:GetTable`, `glue:GetTables`, `glue:GetPartition`, `glue:GetPartitions` — for the databases you expose
* `s3:GetObject` and `s3:PutObject` on the output location
* `s3:GetObject` and `s3:ListBucket` on the buckets your tables read from

Without write access to the output location, every query fails: Athena stages each result set in S3 before it can be read back.

## Connecting Amazon Athena to Upsolve

Now that you have your requirements, you can connect it to Upsolve using the following steps:

1. Navigate to the connections page in Upsolve.
2. Click to add a new connection and select **Athena** as your data source type.
3. Enter a name for your connection, then fill in the details:

* Region
* Access Key ID
* Secret Access Key
* S3 output location
* Database
* Data catalog (optional)
* Workgroup (optional)

4. Click "Test & Create Connection" to validate the credentials and create your Athena connection.

Congratulations! You've successfully created a new data source between Amazon Athena and Upsolve.

## Things to know about Athena

* **Athena uses Trino/Presto SQL.** Identifiers are double-quoted, and date handling uses `date_trunc` and `date_format` rather than their Postgres or MySQL equivalents.
* **Queries are billed per byte scanned.** Upsolve therefore disables automatic selectable-column detection for Athena connections — detecting it would run a `COUNT` per table on every metadata refresh. Partitioning your tables and filtering on the partition keys is the most effective way to control cost.
* **Executions are asynchronous.** Upsolve polls until a query completes and gives up after 120 seconds.
* **One database per connection.** Unlike other connection types, the database field cannot be a comma-separated list, because Athena scopes `information_schema` to a single database at a time. Create a separate connection for each database you need.

<Note>
  The specific steps for connecting Amazon Athena may vary based on your unique
  setup. If you encounter any difficulties or have questions, please don't
  hesitate to contact our Support Team for assistance.
</Note>
