Skip to main content

Amazon Athena

Available for SeekWell

Use this database with SeekWell for analysis. Connect your data to SeekWell using a new connection or credentials copied from an existing Extract connector.

info

Destination Documentation: Amazon Athena Documentation

High-Level Information:

Amazon Athena is an interactive query service that analyzes data in Amazon S3 using standard SQL. Extract integrates with Athena by streaming Parquet files directly to customer-owned S3 and publishing unpartitioned external tables via AWS Glue, without JDBC or Athena write queries. The connector supports Append and Replace load modes for efficient data loading into your AWS data lake.

Prerequisites​

  1. An AWS account with Athena, Glue, and S3 access
  2. An existing Glue database in the target region
  3. An S3 bucket for storing Parquet data
  4. IAM credentials with appropriate permissions

Setup Guide​

Step 1: Create or identify a Glue database​

The Athena destination writes to Glue-managed external tables. Ensure you have a Glue database:

-- In Athena Query Editor
CREATE DATABASE IF NOT EXISTS extract_data;

Or create via AWS Console: AWS Glue > Databases > Add database

Step 2: Create or identify an S3 bucket​

Create or identify an S3 bucket to store the Parquet data:

  • The bucket must be in the same region as your Glue database
  • Configure appropriate lifecycle policies for your retention needs
  • Enable server-side encryption (SSE-S3 or SSE-KMS recommended)

Step 3: Create IAM credentials​

Create an IAM user or role with the following permissions:

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"glue:GetDatabase",
"glue:GetTable",
"glue:CreateTable",
"glue:UpdateTable"
],
"Resource": [
"arn:aws:glue:<region>:<account-id>:catalog",
"arn:aws:glue:<region>:<account-id>:database/<database-name>",
"arn:aws:glue:<region>:<account-id>:table/<database-name>/*"
]
},
{
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:PutObject",
"s3:PutObjectAcl",
"s3:AbortMultipartUpload"
],
"Resource": [
"arn:aws:s3:::<bucket-name>",
"arn:aws:s3:::<bucket-name>/*"
]
}
]
}

Replace placeholder values with your actual AWS account ID, region, database name, and bucket name.

Athena readers

Users who query the tables via Athena need separate permissions: Athena query execution, Glue table reads, and S3 GetObject on the data prefix.

Step 4: Configure the Amazon Athena destination in Extract​

In the Extract platform, configure the Amazon Athena destination connector with the following parameters:

Connection Settings:

ParameterTypeRequiredDescription
regionstringYesAWS region where your Glue database is located (e.g., us-east-1).
databasestringYesGlue database name where tables will be created. Must use lowercase letters, digits, and underscores only.
bucketstringYesS3 bucket name for storing Parquet data files.
prefixstringNoS3 prefix within the bucket. Default: extract-athena.
access_key_idstringYesAWS IAM Access Key ID with Glue and S3 permissions.
secret_access_keystringYesAWS IAM Secret Access Key.
session_tokenstringNoAWS session token for temporary credentials.

Step 5 (Optional): Configure multipart upload cleanup​

Configure S3 lifecycle rules to clean up incomplete multipart uploads in case of worker failures:

{
"Rules": [
{
"ID": "AbortIncompleteMultipartUpload",
"Status": "Enabled",
"Filter": {
"Prefix": "extract-athena/"
},
"AbortIncompleteMultipartUpload": {
"DaysAfterInitiation": 7
}
}
]
}

Load Modes​

The Athena destination supports the following load modes:

Append​

Adds new data to an existing table without modifying existing rows.

  • Requires the selected schema (column names, types, and order) to match the existing table
  • Glue metadata is updated before uploading to prevent partial batches from becoming visible
  • Each connection run creates one complete Parquet object

Replace​

Replaces all data in the table with the new dataset.

  • Supports schema changes (new columns, type changes)
  • Writes to an isolated generation prefix before updating the Glue table location
  • Previous generations are retained for in-flight queries
  • Empty snapshots create empty Parquet tables (not deleted)

NoData behavior​

When a source completes with no data:

  • Replace: Publishes an empty Parquet table
  • NoData setting: Preserves the existing table without changes

How Extract Loads Data​

Extract loads data into Athena using the following process:

  1. Extract: Data is extracted from your source connector
  2. Stream to S3: Records are written as Parquet files directly to your S3 bucket using bounded 32 MiB parts
  3. Advisory locking: A Postgres advisory lock coordinates concurrent writers to the same table
  4. Glue metadata: Table metadata is created or updated in Glue with ownership tracking
  5. Publication: The table location points to the completed data

Storage organization​

Data is organized under each stream's S3 prefix:

s3://<bucket>/<prefix>/tables/<aws-account>/<region>/<database>/<table>/<generation-id>/

This isolation ensures:

  • Different AWS accounts, regions, or databases never share data
  • Changing table name overrides creates a new isolated path
  • Generation IDs enable Replace mode retention

Ownership and coordination​

Extract tracks ownership using Glue table parameters:

  • extract_owner: Identifies the Extract account, connection, and stream that owns this table
  • extract_last_connection_run: Tracks the last successful connection run

Only the owning Extract stream may modify a table. Attempting to write to a table owned by another stream or created outside Extract will fail.

Configuration Parameters​

Table naming requirements​

Table and column names must:

  • Contain only lowercase ASCII letters, digits, and underscores
  • Be 1-255 characters in length
  • Be unique within the database

Schema requirements​

  • At least one column must be selected
  • For Append mode, the schema must match the existing table exactly
  • JSON fields are stored as serialized strings
  • Arrays retain their element types

Supported data types​

Source TypeAthena/Glue Type
Stringstring
Booleanboolean
Integerbigint
Number (float)double
Datedate
Timestamptimestamp
Arrayarray<element-type>

Limitations​

  • Unpartitioned tables only: Partitioned tables are not supported in this version
  • No Iceberg support: Tables are created as standard Hive external tables
  • No Merge/Upsert: Only Append and Replace modes are available
  • Single object per run: Each connection run produces one Parquet object, bounded to approximately 312 GiB (S3's 10,000-part limit with 32 MiB parts)
  • No exactly-once guarantee: S3 completion and source progress are not transactional; a lost upload acknowledgment may replay data on retry

Retention and Cleanup​

Replace mode retention​

When using Replace mode, old generations are retained so in-flight queries can complete. To clean up old generations:

  1. Drain workers using old advisory lock logic
  2. Run the fenced cleanup command (see ops documentation)
  3. Dry-run is the default; apply mode marks inactive generations and waits 7 days before deletion
warning

Do not use blanket age-based S3 expiration rules, as they can delete active Append data.

Rollback behavior​

Disabling the destination:

  • Preserves all existing tables and data for reads
  • No automatic deletion of customer data occurs

Troubleshooting​

IssueResolution
Glue database not foundVerify the database exists in Glue and the region is correct.
Table owned by another streamEach table can only be written by one Extract stream. Create a new table with a different name.
Schema mismatch on AppendAppend requires identical column names, types, and order. Use Replace to change the schema.
Advisory lock timeoutAnother Extract run may be writing to the same table. Wait for it to complete or check for stuck runs.
S3 permission deniedVerify IAM permissions include PutObject and AbortMultipartUpload on the bucket and prefix.
Invalid table/column nameNames must be lowercase letters, digits, and underscores only (1-255 characters).
Object size limit exceededA single run is bounded to ~312 GiB. Split large loads into smaller batches upstream.

Best Practices​

  • Dedicated prefix: Use a dedicated S3 prefix (e.g., extract-athena/) to isolate Extract data from other workloads
  • Lifecycle policies: Configure abort-incomplete-multipart cleanup for the prefix
  • Separate credentials: Use dedicated IAM credentials for Extract with least-privilege permissions
  • Monitor generations: Periodically run the cleanup command to remove old Replace generations
  • External writers: Do not allow external writers or other Extract deployments to modify tables managed by this connector