View a markdown version of this page

Install the extension - Amazon Athena
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Install the extension

Before you install the extension, check that the following prerequisites are met:

  • Use DuckDB 2.0.1 and an extension build for that client version.

  • Use one of the supported platforms in the following table. Linux requires glibc 2.34 or later; Amazon Linux 2 does not meet this requirement.

  • Use a workgroup running DuckDB in a supported Region. See Regions and availability and Step 1: Create a DuckDB workgroup.

  • Configure usable credentials for the default credential chain. To use a named profile, select it with PROFILE on the secret as described in Use a named profile.

  • Grant the query and data permissions in Security and permissions and the extension API permissions in Athena API permissions.

  • Allow HTTPS access to aws.amazon.com and downloads.aws.com for repository registration and extension installation. If the core httpfs and aws extensions are not already installed, also allow download access to your configured DuckDB core-extension repository. Queries also need access to the service endpoints used by your configuration.

Supported platforms
Operating system and architecturePlatform
Linux, x86-64linux_amd64
Linux, ARM64linux_arm64
macOS, Apple siliconosx_arm64
Windows, x86-64windows_amd64

Step 1: Install the extension

Register the repository and install the signed extension with the following commands. Repository registration is saved on your machine. Install the extension for each DuckDB client version you use; after upgrading the client, install a compatible build again. Installation from this repository is an explicit step.

CREATE EXTENSION REPOSITORY aws.amazon.com; INSTALL athena FROM aws.amazon.com;

With extension autoloading and auto-installation enabled, DuckDB installs and loads httpfs as needed for the repository commands. If the repository already exists, registering it again returns a catalog error. To avoid the error, use CREATE OR REPLACE EXTENSION REPOSITORY aws.amazon.com or CREATE EXTENSION REPOSITORY IF NOT EXISTS aws.amazon.com.

Step 2: Load and attach

In each session, run the following commands to load the extension and attach your workgroup. The example uses credentials from the default credential chain. Replace us-west-2 with your Region and my-duckdb-workgroup with your workgroup name.

LOAD athena FROM aws.amazon.com; INSTALL AND LOAD aws; ATTACH 'arn:aws:athena' AS ath (TYPE athena, Region 'us-west-2', WorkGroup 'my-duckdb-workgroup');
ath

The optional local catalog alias created by ATTACH. Keep it when following the later query examples.

TYPE athena

Selects the Athena extension for the attached catalog.

To use a named profile or refreshable temporary credentials, create a DuckDB secret as described in Credentials and required permissions.

For the DuckDB workgroup used in this procedure, leave EngineVersion and athena_engine_version unset. A workgroup that enforces engine version 3 is refused. For an unenforced engine version 3 workgroup, the extension requests DuckDB; the service must allow that selection. Use a DuckDB workgroup for this setup.

Check the installed extension

To inspect the installed extension version and whether it is loaded, run the following query. This query inspects the client's extension installation; it does not list extensions offered by the repository.

SELECT extension_name, extension_version, installed, loaded, installed_from FROM duckdb_extensions() WHERE extension_name = 'athena';

Update the installed extension

To download and install available updates from the registered repositories, run the following command.

UPDATE EXTENSIONS;

An update does not replace an extension already loaded in a running database instance. Close that instance and start a new one to load the updated binary. For the command-line client, exit and restart DuckDB.