How to configure an Athena Datasource

This guide will help you add an Athena instance (or a database) as a Datasource. This will allow you to validate tables and queries within this instance. When you use an Athena Datasource, the validation is done in Athena itself. Your data is not downloaded.

Prerequisites: This how-to guide assumes you have already:


  1. Run the following CLI command to begin the interactive Datasource creation process:

Show Docs for V2 (Batch Kwargs) API

great_expectations datasource new

Show Docs for V3 (Batch Request) API

great_expectations --v3-api datasource new
  1. Choose “other” from the list of database engines, when prompted.

  2. Identify the connection string you would like Great Expectations to use to connect to Athena, using the examples below and the PyAthena documentation.

    The following urls dont include credentials as it is recommended to use either the instance profile or the boto3 configuration file.

    If you want Great Expectations to connect to your Athena instance (without specifying a particular database), the URL should be:


    Note the url parameter “s3_staging_dir” needed for storing query results in S3.

    If you want Great Expectations to connect to a particular database inside your Athena, the URL should be:


Show Docs for V2 (Batch Kwargs) API

  1. Enter the connection string when prompted (and press Enter when asked “Would you like to proceed? [Y/n]:”).

  2. Should you need to modify your connection string, you can manually edit the great_expectations/uncommitted/config_variables.yml file.

Show Docs for V3 (Batch Request) API

  1. You will be presented with a Jupyter Notebook which will guide you through the steps of creating a Datasource.

  2. Follow the steps in this Jupyter Notebook including entering the connection string in the yaml configuration.

Additional notes

Environment variables can be used to store the SQLAlchemy URL instead of the file, if preferred - search documentation for “Managing Environment and Secrets”.

Additional resources