Amazon S3 is widely used to store application data, business reports, transaction records, logs, and analytics datasets. As organizations collect more information, they need efficient ways to analyze these files without building and maintaining a large database infrastructure.
DuckDB and Amazon Athena provide two useful approaches to this problem.
DuckDB is an analytical database designed to execute SQL queries efficiently, including queries against remote files stored in Amazon S3. Amazon Athena is a serverless query service that allows developers and data analysts to run SQL directly against data stored in S3.
Although both tools can analyze S3 data, they work differently.
DuckDB can download only the required portions of supported files and process the data locally. Athena executes supported queries through AWS-managed infrastructure and returns the results to the client.
Developers can also connect DuckDB to Amazon Athena using the AWS-maintained Athena extension. This makes it possible to work with Athena tables from a DuckDB environment and combine remote query results with local datasets.
In this article, we will explore how to configure DuckDB for Amazon S3, authenticate using AWS credentials, query Parquet files, connect DuckDB to Amazon Athena, combine datasets, and choose the right approach for production workloads.
1. Understanding DuckDB and Amazon Athena
Before implementing the integration, it is important to understand what each technology does.
What Is DuckDB?
DuckDB is an analytical database that supports SQL queries and is designed for analytical workloads.
Unlike traditional database servers, DuckDB can run directly inside an application, command-line tool, notebook, or data-processing environment.
It is particularly useful for:
- Analyzing CSV and Parquet files.
- Running SQL queries against local datasets.
- Querying remote files stored in Amazon S3.
- Performing aggregations and joins.
- Preparing data for reporting and machine learning.
- Combining data from different sources.
For example, suppose an organization stores millions of transaction records in Parquet files on Amazon S3.
Instead of importing every file into a separate database, DuckDB can query the files directly.
SELECT
COUNT(*) AS total_orders,
SUM(order_amount) AS total_revenue
FROM 's3://company-data/orders/orders.parquet';
DuckDB reads the required data from S3 and executes the SQL query.
What Is Amazon Athena?
Amazon Athena is a serverless interactive query service provided by AWS.
It allows developers to analyze data stored in Amazon S3 using SQL without provisioning database servers.
Athena commonly works with:
- Amazon S3.
- AWS Glue Data Catalog.
- Apache Parquet.
- Apache ORC.
- CSV.
- JSON.
- Apache Iceberg.
For example, suppose a company has registered its transaction files as an Athena table named orders.
You can execute:
SELECT
COUNT(*) AS total_orders,
SUM(order_amount) AS total_revenue
FROM orders;
Athena manages the query execution infrastructure and processes the data according to the configured workgroup and query engine.
DuckDB vs. Amazon Athena
| Feature | DuckDB | Amazon Athena |
|---|
| Architecture | Embedded analytical database | Serverless query service |
| Query execution | Local or application-hosted | AWS-managed |
| S3 integration | Direct S3 file access | Native AWS integration |
| SQL support | DuckDB SQL | Athena-supported SQL |
| Data catalog | Can integrate with AWS Glue | AWS Glue integration |
| Infrastructure | Runs in your environment | Managed by AWS |
| Query results | Returned by DuckDB | Managed or stored in S3 |
| Best suited for | Local analytics and data processing | Serverless analytics on S3 |
The important difference is where the query executes.
When DuckDB directly reads an S3 file, DuckDB performs the analytical processing in its own environment.
When Athena executes a query, AWS manages the processing infrastructure.
This distinction becomes important when choosing between the two approaches.
2. Understanding the Architecture
There are two primary ways to work with S3 data using DuckDB and Athena.
Approach 1: Query S3 Directly With DuckDB
In this approach, DuckDB connects directly to Amazon S3 using its HTTPFS extension.
Application / Developer
|
v
DuckDB
|
v
HTTPFS Extension
|
v
Amazon S3 Bucket
|
v
CSV / Parquet Files
DuckDB reads the required files or file portions and performs SQL operations locally.
This approach is useful when you want to analyze files without first registering them in Athena.
Approach 2: Connect DuckDB to Amazon Athena
In this approach, DuckDB uses the Athena extension maintained by AWS.
Application / Developer
|
v
DuckDB
|
v
Athena Extension
|
v
Amazon Athena
|
v
AWS Glue Catalog
|
v
Amazon S3
|
v
Query Results
DuckDB attaches an Athena data catalog and exposes its databases and tables through DuckDB's database interface.
You can then query Athena tables using SQL from DuckDB.
The Athena extension also supports sending SQL statements directly to Athena through its query functions.
These two approaches are complementary. Direct S3 access is useful for file-based analytics, while the Athena extension is useful when you want to work with an existing Athena environment.
3. Prerequisites
Before starting the implementation, prepare the following:
| Requirement | Purpose |
|---|
| Python 3 | Run DuckDB examples through Python |
| DuckDB 2.0.1 or later | Use the AWS service extension repository workflow |
| AWS account | Access Amazon S3 and Athena |
| S3 bucket | Store analytical datasets |
| AWS credentials | Authenticate with AWS |
| AWS region | Identify the location of S3 and Athena resources |
| Athena workgroup | Configure query execution |
| AWS Glue Data Catalog | Register tables for Athena queries |
You can install DuckDB using pip.
pip install duckdb
Check the installed version:
python -c "import duckdb; print(duckdb.__version__)"
The AWS Athena extension described in this article requires DuckDB 2.0.1 or later for the repository registration process.
Use compatible extension versions and verify the current extension documentation before deploying the integration.
4. Configure AWS Credentials
DuckDB needs valid AWS credentials to access private S3 buckets.
There are different ways to provide credentials, including:
- AWS CLI profiles.
- Environment-based credentials.
- IAM roles.
- AWS IAM Identity Center.
- Temporary credentials.
- Static access keys.
For development environments, using an existing AWS CLI profile is convenient.
Configure AWS CLI
Install the AWS CLI if it is not already available.
Then configure a profile:
aws configure
Provide the required values:
AWS Access Key ID
AWS Secret Access Key
Default region name
Default output format
For organizations using AWS IAM Identity Center, authenticate through the CLI:
aws configure sso
Then sign in:
aws sso login --profile analytics-profile
DuckDB can use credentials from the configured AWS environment through its credential chain.
Avoid hardcoding long-lived access keys in application source code.
For production applications running on AWS, prefer temporary credentials obtained through an appropriate IAM role.
5. Install and Configure the DuckDB HTTPFS Extension
DuckDB uses the HTTPFS extension to read and write files stored on remote object storage services that support the S3 API.
HTTPFS provides functionality such as:
- Reading Parquet files from S3.
- Reading CSV files from S3.
- Reading multiple files using wildcard patterns.
- Performing partial file reads.
- Writing supported files to S3.
- Uploading files using multipart upload.
Open DuckDB and execute:
INSTALL httpfs;
LOAD httpfs;
The INSTALL command downloads and installs the extension.
The LOAD command makes it available in the current database session.
DuckDB can also automatically load HTTPFS when S3 functionality is first used.
Configure an AWS Credential Chain
For a development environment with an existing AWS CLI profile, create an S3 secret.
INSTALL aws;
LOAD aws;
CREATE SECRET (
TYPE s3,
PROVIDER credential_chain,
CHAIN config,
PROFILE 'analytics-profile',
REGION 'ap-south-1'
);
Replace the profile and region with your actual configuration.
Here is what each option means:
- TYPE s3 identifies the secret as an S3 credential.
- PROVIDER credential_chain tells DuckDB to retrieve credentials through the AWS SDK.
- CHAIN config selects the AWS configuration and profile-based credential chain.
- PROFILE selects the configured AWS profile.
- REGION specifies the AWS region.
The credential_chain provider is part of DuckDB's AWS extension.
For production environments, the same mechanism can use supported role-based credential sources rather than a developer's local profile.
Verify the S3 Configuration
You can inspect the configured secrets using:
SELECT *
FROM duckdb_secrets();
Sensitive values are redacted.
You can also check which secret DuckDB selects for an S3 path:
SELECT *
FROM which_secret(
's3://company-data/orders/orders.parquet',
's3'
);
This is useful when multiple credentials or scoped secrets are configured.
6. Query Parquet Files Directly From Amazon S3
Parquet is a column-oriented file format commonly used for analytical workloads.
It stores data in a structure that allows analytical engines to read selected columns without loading every field from a file.
Suppose an organization stores order information in this S3 location:
s3://company-data/orders/orders.parquet
The file contains the following columns:
| Column | Description |
|---|
| order_id | Unique order identifier |
| customer_id | Customer identifier |
| order_date | Order creation date |
| order_amount | Total order amount |
| status | Order status |
You can query the file directly:
SELECT *
FROM 's3://company-data/orders/orders.parquet'
LIMIT 10;
You do not need to import the file into a separate database table first.
Calculate Total Revenue
You can execute normal analytical SQL queries against the remote file.
SELECT
COUNT(*) AS total_orders,
SUM(order_amount) AS total_revenue,
AVG(order_amount) AS average_order_value
FROM 's3://company-data/orders/orders.parquet';
DuckDB reads the required columns and performs the calculations.
Filter Data Using a WHERE Clause
Suppose you want to analyze completed orders.
SELECT
customer_id,
COUNT(*) AS total_orders,
SUM(order_amount) AS total_spent
FROM 's3://company-data/orders/orders.parquet'
WHERE status = 'Completed'
GROUP BY customer_id
ORDER BY total_spent DESC
LIMIT 20;
This query identifies the customers who have generated the highest completed-order revenue.
Column projection and filter pushdown can reduce unnecessary data access when the file format and query plan support them.
7. Query Multiple Parquet Files From S3
In real projects, datasets are often divided into multiple files.
For example:
s3://company-data/orders/
orders-2026-01.parquet
orders-2026-02.parquet
orders-2026-03.parquet
orders-2026-04.parquet
Instead of querying each file separately, DuckDB can read multiple files through a wildcard pattern.
SELECT *
FROM read_parquet(
's3://company-data/orders/*.parquet'
);
You can also calculate monthly revenue across all matching files.
SELECT
DATE_TRUNC('month', order_date) AS order_month,
COUNT(*) AS total_orders,
SUM(order_amount) AS monthly_revenue
FROM read_parquet(
's3://company-data/orders/*.parquet'
)
GROUP BY order_month
ORDER BY order_month;
This is useful when datasets are organized into multiple files based on time or business categories.
Use the Filename Option
The filename option adds the source file name to the query result.
SELECT *
FROM read_parquet(
's3://company-data/orders/*.parquet',
filename = true
);
This can help when troubleshooting datasets or identifying which source file contains a particular record.
8. Use Hive Partitioning to Improve Data Organization
Partitioning is an important technique for organizing large analytical datasets.
Instead of storing all order records in one large file, an organization can divide the data into directories based on year and month.
For example:
s3://company-data/orders/
year=2025/
month=11/
month=12/
year=2026/
month=01/
month=02/
month=03/
These directories follow Hive-style partition naming.
DuckDB can automatically recognize partition columns when reading compatible Parquet datasets.
For example:
SELECT
year,
month,
COUNT(*) AS total_orders,
SUM(order_amount) AS revenue
FROM read_parquet(
's3://company-data/orders/**/*.parquet',
hive_partitioning = true
)
WHERE year = 2026
AND month = 3
GROUP BY year, month;
Partitioning allows the query engine to avoid reading files from unrelated partitions when the query conditions can be pushed down.
For example, if you are analyzing March 2026, there is no reason to scan every file from 2025.
Good partition design can reduce unnecessary S3 reads and improve query performance.
However, avoid creating too many tiny partitions. Excessive small files and metadata operations can increase overhead.
9. Connect DuckDB to the AWS Glue Data Catalog
When an organization already uses Amazon Athena, its tables are commonly registered in the AWS Glue Data Catalog.
The catalog stores metadata about datasets, including database names, table names, column definitions, and storage locations.
DuckDB provides a Glue extension that can attach the AWS Glue Data Catalog as a database.
Install and load it:
INSTALL glue;
LOAD glue;
Create an AWS credential secret:
CREATE SECRET (
TYPE s3,
PROVIDER credential_chain,
REGION 'ap-south-1'
);
Attach the Glue catalog:
ATTACH '123456789012' AS company_catalog (
TYPE glue,
READ_ONLY true
);
Replace the example account identifier with the AWS account ID associated with the catalog.
You can now list available tables:
SHOW ALL TABLES;
Query a registered table:
SELECT *
FROM company_catalog.analytics.orders
LIMIT 20;
Here:
- company_catalog is the attached DuckDB database.
- analytics is the Glue database.
- orders is the registered table.
The Glue extension supports Glue's native Hive tables stored in formats such as Parquet, CSV, JSON, and Avro.
It does not provide general read and write support for every table format registered in Glue. For Iceberg tables, use DuckDB's Iceberg extension instead.
Also note that the Glue extension introduced in DuckDB 2.0 is experimental according to its documentation. Evaluate its compatibility and operational requirements before using its DDL and DML functionality in production.
10. Install the Amazon Athena Extension
If your goal is to execute queries through Amazon Athena rather than directly reading files from S3, use the Athena extension.
An important distinction is that the Athena extension is not maintained as a DuckDB core extension.
AWS develops and maintains it and distributes it through its own extension repository.
First, register the AWS extension repository:
CREATE EXTENSION REPOSITORY aws.amazon.com;
This repository registration requires DuckDB 2.0.1 or later.
Next, install and load the Athena extension:
INSTALL AND LOAD athena FROM aws.amazon.com;
The extension depends on HTTPFS, which it loads automatically.
In later sessions, load the extension from the AWS repository:
LOAD athena FROM aws.amazon.com;
This distinction matters because extensions installed from a custom repository are not automatically loaded using the normal core-extension lookup.
11. Configure Credentials for the Athena Extension
The Athena extension uses a DuckDB secret to sign its AWS requests.
It supports credentials through a secret of type aws or s3.
For example, create an AWS secret using the credential chain:
LOAD aws;
CREATE SECRET aws_identity (
TYPE aws,
PROVIDER credential_chain,
REFRESH 'auto'
);
The credential chain can obtain credentials from supported AWS sources, including environment configuration, profiles, SSO, assumed roles, and instance metadata.
For temporary credentials, automatic refresh is particularly important.
The extension uses the secret to authenticate its requests to AWS services.
Do not assume that the Athena extension automatically reads credentials from your environment or AWS configuration files without a DuckDB secret. Configure the secret explicitly.
12. Attach an Amazon Athena Data Catalog
After configuring the credentials and installing the extension, attach an Athena data catalog.
For example:
ATTACH 'athena://ap-south-1' AS ath (
TYPE athena
);
Here:
- athena:// identifies the Athena connection.
- ap-south-1 is the AWS region.
- ath is the local DuckDB alias.
- TYPE athena selects the Athena extension.
The default Athena workgroup is primary unless another workgroup is configured.
You can also specify a workgroup:
ATTACH 'athena://ap-south-1/analytics-workgroup' AS ath (
TYPE athena
);
If you want a specific Athena database to become the default schema, configure the Database option:
ATTACH 'athena://ap-south-1' AS ath (
TYPE athena,
WorkGroup 'analytics-workgroup',
Catalog 'AwsDataCatalog',
Database 'analytics'
);
Before attaching the catalog, make sure the Athena workgroup has a valid query-result configuration.
Depending on the workgroup, results can use Athena-managed storage or an S3 query-result location.
When a customer-owned S3 result location is configured, the executing principal must have the required permissions to write results there.
13. Query Athena Tables Through DuckDB
Once the Athena catalog is attached, its databases and tables become accessible through DuckDB.
Athena organizes its objects as:
Data Catalog
|
+-- Database
|
+-- Table
DuckDB maps these objects as:
Attached Database
|
+-- Schema
|
+-- Table
For example, suppose Athena contains:
Catalog: AwsDataCatalog
Database: analytics
Table: orders
If the catalog is attached using the alias ath, you can query the table as follows:
SELECT
order_id,
customer_id,
order_amount
FROM ath.analytics.orders
LIMIT 20;
You can also run aggregations:
SELECT
status,
COUNT(*) AS total_orders,
SUM(order_amount) AS total_revenue
FROM ath.analytics.orders
GROUP BY status
ORDER BY total_revenue DESC;
The Athena extension can execute supported SQL against Athena and return the results to DuckDB.
This is particularly useful when analysts want to work with an existing Athena catalog without changing their entire analytical workflow.
14. Combine Athena Results With Local DuckDB Data
One of the most useful capabilities is combining data from Athena with local data.
Consider a company that stores historical orders in Amazon S3 and maintains a small customer mapping file locally.
The Athena catalog contains an orders table:
SELECT *
FROM ath.analytics.orders;
The local dataset contains customer information:
CREATE TABLE customer_mapping (
customer_id INTEGER,
customer_segment VARCHAR
);
INSERT INTO customer_mapping VALUES
(101, 'Enterprise'),
(102, 'Business'),
(103, 'Individual');
You can join the Athena table with the local DuckDB table:
SELECT
o.customer_id,
c.customer_segment,
COUNT(*) AS total_orders,
SUM(o.order_amount) AS total_revenue
FROM ath.analytics.orders o
INNER JOIN customer_mapping c
ON o.customer_id = c.customer_id
GROUP BY
o.customer_id,
c.customer_segment
ORDER BY total_revenue DESC;
This approach is useful when:
- Historical information is stored in Athena.
- Reference data is stored locally.
- Temporary datasets are generated by Python applications.
- Analysts need to combine cloud and local data.
- Reports require information from multiple sources.
Understand Query Pushdown
Query pushdown means sending suitable parts of a query to the remote data engine instead of retrieving all the source data and processing it locally.
The Athena extension supports remote query execution and pushdown settings.
For example, when remote pushdown is enabled, a query that only reads tables from one attached Athena catalog can be sent to Athena as a complete query.
When combining Athena tables with local DuckDB tables, query planning and execution can involve both environments.
This matters because moving large datasets from Athena into DuckDB can create unnecessary network traffic and additional processing.
Use EXPLAIN to inspect the query plan:
EXPLAIN
SELECT
status,
COUNT(*)
FROM ath.analytics.orders
GROUP BY status;
The plan helps you understand whether the query is executed remotely or whether DuckDB performs additional processing locally.
For production workloads, verify the behavior of the installed Athena extension version and its pushdown settings rather than assuming every query is executed entirely in Athena.
15. Query Athena Directly Using athena_query
The Athena extension also provides functions for sending SQL statements directly to Athena.
For example:
SELECT *
FROM athena_query(
'ath',
'SELECT COUNT(*) AS total_orders
FROM analytics.orders'
);
The first argument identifies the attached Athena connection.
The second argument contains the SQL statement that should run in Athena.
This approach is useful when you want to explicitly send a SQL query to Athena instead of writing it as a regular DuckDB table query.
The extension also provides athena_execute for statements that execute through Athena.
Use the appropriate function for the intended operation and check the installed extension documentation for the supported statement types and restrictions.
An important detail is that the SQL passed to Athena must be valid for the configured Athena execution environment.
DuckDB SQL and Athena SQL are not identical in every situation.
16. Write Analytical Results Back to Amazon S3
DuckDB can also write analytical results to S3.
This is useful when you want to generate a summarized dataset that another application or analytics tool can consume.
For example, consider a query that calculates monthly revenue.
CREATE TABLE monthly_revenue AS
SELECT
DATE_TRUNC('month', order_date) AS revenue_month,
COUNT(*) AS total_orders,
SUM(order_amount) AS revenue
FROM 's3://company-data/orders/*.parquet'
GROUP BY revenue_month;
You can export the result as a Parquet file:
COPY monthly_revenue
TO 's3://company-reports/monthly-revenue.parquet'
(FORMAT PARQUET);
DuckDB uses the S3 upload functionality provided by HTTPFS.
For larger datasets, you can write partitioned output:
COPY monthly_revenue
TO 's3://company-reports/monthly-revenue'
(
FORMAT PARQUET,
PARTITION_BY (revenue_month)
);
Partitioned output can make future analytical queries more efficient when consumers filter by the partition columns.
Before writing to S3, verify that the configured credentials have the required write permissions.
Also, do not assume that writing a Parquet file directly to S3 automatically registers it as a table in Athena.
If you want Athena to discover the output as a table, register its metadata through the appropriate catalog workflow.
17. Understand Query Costs and Performance
Performance and cost are important when choosing between DuckDB and Athena.
DuckDB Directly Querying S3
When DuckDB reads S3 files directly, consider:
- S3 data transfer and request costs.
- Number of objects accessed.
- Amount of data read.
- Network bandwidth.
- Local CPU and memory usage.
- Storage format and partition design.
Parquet is often a good choice for analytical workloads because its columnar structure allows engines to avoid reading unnecessary columns.
For example:
SELECT
SUM(order_amount)
FROM 's3://company-data/orders/*.parquet';
This query requires fewer columns than:
SELECT *
FROM 's3://company-data/orders/*.parquet';
Avoid selecting every column when the application needs only a few fields.
Amazon Athena
Athena query costs depend on the selected pricing model and service configuration.
For traditional data-scanned pricing, the amount of data scanned is an important factor.
For example, selecting a few columns from Parquet files can reduce the amount of data processed.
Partitioning can also reduce unnecessary scanning when queries filter on partition columns.
Other considerations include:
- Query execution time.
- Workgroup configuration.
- Query concurrency.
- S3 storage and request costs.
- Query-result storage.
- Encryption and data-transfer requirements.
Athena's pricing model and available query features can change. Review current AWS pricing before estimating production costs.
Performance Optimization Checklist
| Optimization | Benefit |
|---|
| Use Parquet | Reduces unnecessary column reads |
| Use partitioning | Avoids scanning unrelated data |
| Select required columns | Reduces data access |
| Filter early | Limits the records processed |
| Avoid excessive small files | Reduces metadata and request overhead |
| Use appropriate file sizes | Improves analytical processing |
| Cache reusable results | Avoids repeated work where appropriate |
| Inspect query plans | Helps identify unnecessary data movement |
18. Security and IAM Permissions
Security should be considered before connecting DuckDB or Athena to production S3 datasets.
A common mistake is granting broad permissions to simplify the initial setup.
Instead, use least-privilege IAM policies.
For direct S3 access through DuckDB, the application generally needs only the required permissions for the relevant bucket and objects.
Common permissions include:
- s3:ListBucket when listing or globbing objects.
- s3:GetObject when reading files.
- s3:PutObject when writing files.
- Additional multipart upload permissions when required.
For Athena, permissions may include:
- Athena query execution permissions.
- Workgroup access.
- AWS Glue Data Catalog access.
- S3 permissions for source datasets.
- S3 permissions for query results.
- AWS KMS permissions when encrypted objects or results are involved.
The exact permissions depend on the query, data catalog, workgroup, storage configuration, and encryption settings.
Protect Query Results
Athena query results can contain sensitive information.
When using a customer-owned S3 query-result location, configure:
- Bucket policies.
- IAM permissions.
- Encryption.
- Lifecycle policies.
- Appropriate retention.
- Access controls for result files.
A particularly important security detail is that permission to read Athena result objects directly from S3 can provide access to query results even if the principal does not have Athena's GetQueryResults permission.
Therefore, protect the result bucket as carefully as the source dataset.
19. Common Mistakes and Troubleshooting
Access Denied Errors
If DuckDB cannot read an S3 file, verify:
- The AWS credentials are valid.
- The selected profile is correct.
- The bucket and object permissions are configured.
- The region is correct.
- The object path is valid.
- KMS permissions are available if the object is encrypted.
For Athena, also check workgroup and Glue permissions.
HTTP HEAD Connection Errors
S3 access can fail when the endpoint or region is configured incorrectly.
Verify the bucket region and S3 endpoint configuration.
Also check whether a proxy, firewall, or network restriction is blocking the required requests.
Athena Cannot Attach the Catalog
Check that:
- The Athena extension is installed from the AWS repository.
- The repository is registered.
- The AWS secret exists.
- The secret has the correct credentials.
- The Athena workgroup exists.
- The workgroup has a valid query-result configuration.
- The configured region matches the Athena resource.
Query Results Are Not Available
Athena stores results according to the workgroup's configuration.
If the workgroup uses a customer-owned S3 location, check that the execution role can write to the location and that the client has the required permissions to read the results.
If encryption is enabled, verify the relevant KMS permissions.
Queries Are Taking Too Long
Check whether the query scans unnecessary files.
Review partitioning, file format, column selection, and filters.
For DuckDB, inspect the query plan and verify how much data is being read from S3.
For Athena, review query execution statistics and data scanned.
DuckDB and Athena Return Different Results
Differences can occur because of SQL dialect behavior, data type conversions, null handling, timestamp interpretation, or query execution settings.
Validate the SQL and compare the source data types before assuming that one engine is producing incorrect results.
20. When Should You Use DuckDB or Amazon Athena?
The best option depends on the workload.
Choose DuckDB for direct S3 analytics when:
- You want to query Parquet files without setting up Athena tables.
- You need local analytical processing.
- You want to combine remote files with local datasets.
- You are building data-processing scripts or analytical applications.
- You need a lightweight SQL engine embedded in an application.
Choose Amazon Athena when:
- Your organization already uses Athena and AWS Glue.
- Multiple teams need managed SQL access to S3 datasets.
- You want AWS-managed query execution.
- You need centralized workgroups and query management.
- Your analytical workload benefits from a serverless query service.
Use the Athena extension when:
- You want to access Athena tables from DuckDB.
- You need to combine Athena results with local DuckDB data.
- You want to keep Athena as the remote query engine while using DuckDB as part of your analytical workflow.
Conclusion
DuckDB and Amazon Athena make it easier to analyze data stored in Amazon S3 without requiring developers to build and maintain a traditional database server for every analytical workload.
DuckDB provides direct access to remote files through HTTPFS, supports AWS authentication through its credential system, and can query Parquet datasets using familiar SQL.
Amazon Athena provides serverless query execution over S3 data. With the AWS-maintained Athena extension, DuckDB can attach an Athena catalog, query registered tables, and combine remote results with local datasets.
The most important decision is understanding where the query should execute. Use direct DuckDB queries when local analytical processing is appropriate. Use Athena when you need AWS-managed query execution. Combine both when your application benefits from remote SQL processing and local data analysis.
For production systems, pay attention to IAM permissions, S3 partitioning, Parquet file organization, query-result security, and data-scanned costs. These decisions have a direct impact on performance, reliability, and operational expenses.
Join the conversation! Your thoughts help the community grow.