View a markdown version of this page

Configure 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).

Configure the extension

Extension settings become available after you load the extension. To change a setting before you run ATTACH, first run LOAD athena FROM aws.amazon.com;.

Use SET to change a setting for the session, and RESET to restore its default. A setting that is read at ATTACH applies to catalogs that you attach afterward.

SET setting = value; RESET setting;

Requests and query execution

The following table lists settings for requests and query execution.

SettingDefaultBehavior
athena_endpointRegion public endpointAthena endpoint override; read at ATTACH.
athena_glue_endpointRegion public endpointGlue endpoint for listing table buckets with S3Tables '*'.
athena_workgroupprimaryWorkgroup when the ATTACH path does not name one.
athena_engine_versionNot setEngine named on submissions when ATTACH did not pin an engine; leave unset for the workgroup-based setup.
athena_poll_ms200Maximum polling wait, in milliseconds, during the first five seconds. 0 uses the default of 200; values above 60000 are treated as 60000. Later waits grow to the larger of this effective value and 2,000 milliseconds.
athena_timeout_seconds900Seconds an execution can remain unfinished before the extension sends a stop request. 0 uses the default of 900; values above 31536000 are treated as 31536000. If the execution completed before the stop took effect, the statement preserves its final state.
athena_log_httpfalseLog Athena and Glue requests to the DuckDB HTTP log; excludes result stream reads.

Metadata

The following table lists metadata settings.

SettingDefaultBehavior
athena_lazy_schema_listingtrueDefer database listing until needed; read at ATTACH. Catalogs with S3Tables list at ATTACH.
athena_single_table_lookuptrueLook up a named table individually until the database is listed; read at ATTACH.
athena_metadata_cache_scopetransactionRefresh metadata each transaction, or set connection to retain it until rollback, a write or DDL submitted through the attached catalog or athena_execute, or CALL athena_clear_cache(). Writes through athena_query do not clear this cache. Changes apply from the next transaction.
athena_metadata_concurrency2Concurrent database reads for catalog-wide listing until throttled; 1 reads sequentially.

Metadata calls share the account Athena throttling rate across clients.

With athena_metadata_cache_scope = 'connection', cached metadata can remain stale after other clients change tables or databases. Call athena_clear_cache() to refresh the next lookup in the attached catalogs. Use the following commands to refresh cached table listings after another client changes the database.

SET athena_metadata_cache_scope = 'connection'; SELECT table_name FROM information_schema.tables WHERE table_catalog = 'ath' AND table_schema = 'my_database'; CALL athena_clear_cache(); SELECT table_name FROM information_schema.tables WHERE table_catalog = 'ath' AND table_schema = 'my_database'; RESET athena_metadata_cache_scope;

Result retrieval

The following table lists result retrieval settings.

SettingDefaultBehavior
athena_fetch_size0 (10,000 rows)Target rows per ranged S3 comma-separated values (CSV) read; maximum 1,000,000.
athena_decode_threads4Threads that decode Arrow result batches in parallel. 1 decodes on the query thread; the maximum is 64.
athena_stream_buffer_bytes8388608Per-stream decode buffer budget, with a minimum of 65536 bytes. It accounts for framed data awaiting decoding and decoded batches awaiting delivery. A whole message can exceed the budget. It does not cap the separate HTTP queue or total process memory.
athena_schema_cache_entries100Statement shapes whose result schemas the connection retains.
athena_max_fragment_bytes68719476736Maximum bytes per streamed result; 0 removes the cap.
athena_stream_stall_seconds300Seconds without source progress during an active wait for data or for the response to end before the stream is abandoned; time blocked by backpressure is excluded. 0 removes the guard.

Query pushdown

The following table lists pushdown settings.

SettingDefaultBehavior
athena_enable_remote_pushdowntruePush eligible statements to Athena; read at ATTACH. When false, reads run locally over per-table reads. Writes and data definition language (DDL) statements still run on Athena unless they contain a query, other than a view body, that is neither a VALUES list nor a SELECT without FROM.
athena_enable_filter_pushdowntrueInclude eligible local plan filters in per-table reads; other filters are applied locally.

Inspect per-table reads

Set athena_enable_remote_pushdown before attaching the catalog to keep its queries local over per-table reads. Then set athena_enable_filter_pushdown to false to inspect a read without the local plan filter in the SQL sent to Athena. The following example logs a read of a table with product and units columns.

SET athena_enable_remote_pushdown = false; ATTACH 'athena://us-west-2/my-duckdb-workgroup' AS local_reads (TYPE athena, Catalog 's3tablescatalog/amzn-s3-demo-table-bucket', Database 'retail', Secret 'athena_creds'); RESET athena_enable_remote_pushdown; SET athena_enable_filter_pushdown = false; CALL enable_logging('athena', storage := 'memory'); SELECT product FROM local_reads.retail.widget_sales WHERE units > 50 ORDER BY product; SELECT message FROM duckdb_logs WHERE message LIKE '%table scan streamed%' OR message LIKE '%table scan as csv%'; RESET athena_enable_filter_pushdown; DETACH local_reads; CALL disable_logging();