Run your first query using the console
This quickstart walks you through running your first DuckDB query in the Athena console. You create a DuckDB workgroup, create a database and a table, add rows, query them, and then clean up.
You are charged for the queries that you run in this walkthrough. To avoid ongoing charges, complete the cleanup step at the end.
Prerequisites
-
Use an AWS Region where DuckDB is available. For more information, see Regions and availability.
-
Have permission to create workgroups and run queries. For more information, see Security and permissions.
-
Have an Amazon S3 bucket for the table data. In this walkthrough, replace
amzn-s3-demo-bucketwith the name of your bucket.
Step 1: Create a DuckDB workgroup
To create a DuckDB workgroup
-
Open the Athena console at https://console.aws.amazon.com/athena/
. -
In the console navigation pane, under Administration, choose Workgroups.
-
Choose Create workgroup.
-
For Workgroup name, enter a name, such as
my-duckdb-workgroup. -
Under Athena engine version, for Engine version, choose DuckDB.
-
Keep the default query result settings. Athena stores the results of DuckDB queries in managed query results, so you don't need a query result location in Amazon S3.
-
Choose Create workgroup.
For more information about workgroup settings, see Workgroups and query controls.
Step 2: Open the query editor
To open the query editor with your workgroup
-
In the console navigation pane, choose Query editor.
-
For Workgroup, choose the workgroup that you created in Step 1.
-
For Data source, choose AwsDataCatalog.
Each query runs one statement. To run each statement in the following steps, enter it in the query editor and then choose Run.
Step 3: Create a database and a table
Run the following statement to create a database. In DuckDB, a database is a schema.
CREATE SCHEMA duckdb_quickstart
Run the following statement to create a table in the AWS Glue Data Catalog. The WITH clause sets the table type, file format, and data location.
CREATE TABLE duckdb_quickstart.sales ( order_id INTEGER, customer VARCHAR, region VARCHAR, amount DECIMAL(10,2), order_date DATE ) WITH ( type = 'HIVE', format = 'parquet', location = 's3://amzn-s3-demo-bucket/duckdb-quickstart/sales/' )
Step 4: Add rows
Run the following statement to add rows to the table.
INSERT INTO duckdb_quickstart.sales VALUES (1, 'alice', 'east', 120.50, DATE '2026-10-01'), (2, 'bob', 'west', 75.00, DATE '2026-10-01'), (3, 'carol', 'east', 42.25, DATE '2026-10-02')
Step 5: Query the table
Run the following query. The results appear on the Query results tab below the editor.
SELECT region, count(*) AS order_count, sum(amount) AS revenue FROM duckdb_quickstart.sales GROUP BY ALL ORDER BY region
GROUP BY ALL is DuckDB syntax. It groups by every column in the select list that isn't an aggregate. For more SQL, see SQL reference.
Step 6: Clean up
To avoid incurring additional charges, delete the resources that you created in this walkthrough.
To clean up
-
Run the following statement to delete the database and its table.
DROPremoves only the catalog entries. The data files stay in Amazon S3.DROP SCHEMA duckdb_quickstart CASCADE -
In the Amazon S3 console, delete the
duckdb-quickstart/folder from your bucket. -
In the Athena console navigation pane, under Administration, choose Workgroups.
-
Select your workgroup. Choose Actions, and then choose Delete. Confirm the deletion.
Next steps
Now that you have run your first DuckDB query, learn more in the following topics: