This repo provides the Harlequin adapter for Amazon Athena.
harlequin-athena depends on harlequin, so installing this package will also install Harlequin.
To install this adapter into an activated virtual environment:
pip install harlequin-athenapoetry add harlequin-athenaIf you do not already have Harlequin installed:
pip install harlequin-athenaIf you would like to add the Athena adapter to an existing Harlequin installation:
pipx inject harlequin harlequin-athenaAlternatively, you can install Harlequin with the athena extra:
pip install harlequin[athena]poetry add harlequin[athena]pipx install harlequin[athena]For a minimum connection you are going to need:
s3_staging_dir(required): S3 bucket path for query resultsregion(optional, default: us-east-1): AWS region
harlequin -a athena -s s3://my-bucket/athena-results/ -r us-east-1Adapter-specific options can be configured via environment variables. Environment variables are used as fallbacks when CLI options are not provided. The environment variable names follow the pattern HARLEQUIN_ATHENA_<OPTION_NAME> (uppercase with underscores):
HARLEQUIN_ATHENA_S3_STAGING_DIR: S3 staging directory (required)HARLEQUIN_ATHENA_WORK_GROUP: Athena work groupHARLEQUIN_ATHENA_SCHEMA: Default schema (database)HARLEQUIN_ATHENA_CATALOG: Catalog nameHARLEQUIN_ATHENA_POLL_INTERVAL: Polling interval in seconds
Note: AWS credentials and region can be configured using standard AWS SDK environment variables (automatically handled by boto3/pyathena):
AWS_ACCESS_KEY_ID: AWS access key IDAWS_SECRET_ACCESS_KEY: AWS secret access keyAWS_SESSION_TOKEN: AWS session token (for temporary credentials)AWS_REGIONorAWS_DEFAULT_REGION: AWS regionAWS_PROFILE: AWS profile name
Example using environment variables:
# Standard AWS SDK environment variables
export AWS_REGION="us-east-1"
export AWS_PROFILE="my-profile"
# Adapter-specific environment variables
export HARLEQUIN_ATHENA_S3_STAGING_DIR="s3://my-bucket/athena-results/"
export HARLEQUIN_ATHENA_WORK_GROUP="my-workgroup"
harlequin -a athenaThe adapter supports multiple methods for AWS authentication:
-
Default credentials (environment variables, ~/.aws/credentials, or IAM role):
harlequin -a athena -s s3://my-bucket/athena-results/
-
AWS Profile:
harlequin -a athena -s s3://my-bucket/athena-results/ --profile my-profile
-
Explicit credentials:
harlequin -a athena -s s3://my-bucket/athena-results/ \ --aws-access-key-id AKIA... \ --aws-secret-access-key ...
--work-groupor-w: Athena work group to use--schemaor-dor--database: Default schema (database) to use--catalogor-c: Catalog name (default: AwsDataCatalog)--poll-interval: Polling interval in seconds for checking query status (default: 0.5, lower = faster polling)
Example with all options:
harlequin -a athena \
-s s3://my-bucket/athena-results/ \
-r us-east-1 \
-w my-workgroup \
-d my_database \
-c AwsDataCatalogMany more options are available; to see the full list, run:
harlequin --helpFor more information, see the Harlequin Docs.
git clone https://github.com/yourusername/harlequin-athena.git
cd harlequin-athena
poetry installpoetry run pytestNote: Tests require AWS credentials and an Athena setup. You may want to use mocking for CI/CD.
MIT