Work with the AWS Glue Data Catalog
With Athena, powered by DuckDB, you can use the AWS Glue Data Catalog as your metastore. DuckDB stores the databases and tables that you create in the AWS Glue Data Catalog. It can also query the databases and tables that are already in your catalog. These include tables that Athena engine version 3, AWS Glue crawlers, or other engines created. Your data stays in Amazon Simple Storage Service (Amazon S3) or in Amazon S3 table buckets.
This topic gives an overview of how to work with catalog objects. For more information about the syntax of each statement, see the statement topics in SQL reference.
The examples in this topic use a database named sales_db and files under s3://amzn-s3-demo-bucket/. To run the examples, replace these names with your own database and Amazon S3 location.
Catalogs, databases, and table names
The following table lists the catalogs that DuckDB can query in your account and Region.
| Catalog | Name in a query | Contains |
|---|---|---|
| AWS Glue Data Catalog | AwsDataCatalog (default) |
Hive tables and Apache Iceberg tables |
| Amazon S3 Tables | "s3tablescatalog/<table-bucket>" |
Iceberg tables in a table bucket. Each namespace is a database. |
In DuckDB, a database is called a schema. Use CREATE SCHEMA, DROP SCHEMA, and SHOW SCHEMAS in place of CREATE DATABASE, DROP DATABASE, and SHOW DATABASES. A schema is the same AWS Glue database that Athena engine version 3 shows.
A query can refer to a table with a one-part, two-part, or three-part name. Athena fills in the missing parts from the query execution context. If the context does not set a catalog, Athena uses AwsDataCatalog. If the context does not set a database, Athena uses default. The following table shows how Athena reads each form of name.
| Name you write | Table it refers to |
|---|---|
orders |
orders in the context database of the context catalog |
sales_db.orders |
orders in the sales_db database of the context catalog |
awsdatacatalog.sales_db.orders |
orders in the sales_db database of the AWS Glue Data Catalog |
When you write table names, follow these rules:
-
Athena always reads a two-part name as
database.table. -
Quote an identifier with double quotes when it contains special characters, such as
"my-db"."my-table". -
Because the name of an S3 Tables catalog contains a slash, enclose it in double quotes, such as
"s3tablescatalog/amzn-s3-demo-table-bucket".tutorial_ns.daily_orders. You can also set the catalog in the query execution context. -
A query cannot change its default catalog or database. Each query is one statement, and
USEis not supported. To set the defaults, use the query execution context, such as--query-execution-context Catalog=AwsDataCatalog,Database=sales_db.
Table types and supported operations
The following table summarizes which operations each table type supports in this Preview.
| Operation | Hive tables | Iceberg tables (AWS Glue) | S3 Tables |
|---|---|---|---|
SELECT |
Yes | Yes | Yes |
CREATE TABLE, CREATE TABLE AS SELECT (CTAS) |
Yes | Yes | Yes, without location |
INSERT INTO |
Yes | Yes | Yes |
UPDATE, DELETE |
No | Yes | Yes |
MERGE INTO |
Not applicable | No | No |
TRUNCATE |
No | Yes | No |
ALTER TABLE columns |
ADD, DROP, widening |
ADD, DROP, RENAME, widening |
ADD, DROP, RENAME, widening |
| Add, drop, and rename partitions | Yes | No | No |
| Create a partitioned table | Yes | Yes | Yes |
DESCRIBE, SHOW TABLES, EXPLAIN |
Yes | Yes | Yes |
| Time travel | Not applicable | Yes, excluding branches and tags | Yes |
CREATE VIEW over the table |
Yes | No | No |
Table maintenance (OPTIMIZE, VACUUM) |
Not applicable | No | No |
DuckDB does not support Delta Lake, Apache Hudi, or bucketed tables, and it cannot create ORC tables. For more information about the table formats, SerDes, and compression codecs that DuckDB reads and writes, see Table formats, file formats, and SerDes in DuckDB.
Create databases and tables
Run each statement as its own query.
Create a database
Specify database metadata in a WITH (key = value [, ...]) clause, in place of the Athena engine version 3 COMMENT and LOCATION clauses. The comment key sets the AWS Glue database description, and the location key sets its location URI. The following SQL statement creates a database named sales_db.
CREATE SCHEMA sales_db WITH (comment = 'Sales data', location = 's3://amzn-s3-demo-bucket/sales/')
To delete a database and its tables from the catalog, use DROP SCHEMA sales_db CASCADE. The data files stay in Amazon S3. DROP SCHEMA without CASCADE fails if the database has tables.
Create a table
Every CREATE TABLE statement takes its storage settings in a WITH clause. The type property is required, and location is required outside S3 Tables. The following SQL statement creates a Hive table in Parquet format.
CREATE TABLE sales_db.orders_parquet ( order_id INTEGER, customer VARCHAR, amount DECIMAL(10,2), order_date DATE, region VARCHAR ) WITH ( type = 'HIVE', format = 'parquet', location = 's3://amzn-s3-demo-bucket/sales/orders_parquet/' )
The following SQL statement creates an Iceberg table.
CREATE TABLE sales_db.orders ( order_id INTEGER, customer VARCHAR, amount DECIMAL(10,2), order_date DATE ) WITH ( type = 'ICEBERG', location = 's3://amzn-s3-demo-bucket/sales/orders/', 'format-version' = '2' )
A CTAS statement takes the same WITH properties. For more information about table properties, CSV and JSON options, and CTAS, see CREATE TABLE and CREATE TABLE AS statements in DuckDB.
Drop a table
DROP TABLE on a Hive or Iceberg table in the AWS Glue Data Catalog removes only the catalog entry. The data files stay in Amazon S3, so make sure that you delete them, such as with aws s3 rm s3://amzn-s3-demo-bucket/sales/orders/ --recursive. DROP TABLE on an S3 Tables table deletes its data.
Work with partitions
To partition a Hive table, list the partition columns in the column list, and name them again, without types, in PARTITIONED BY. Put PARTITIONED BY before WITH. A CTAS statement can also create a partitioned table. The following SQL statement creates a Hive table that is partitioned by order_date.
CREATE TABLE sales_db.orders_by_day ( order_id INTEGER, customer VARCHAR, amount DECIMAL(10,2), order_date DATE ) PARTITIONED BY (order_date) WITH ( type = 'HIVE', format = 'parquet', location = 's3://amzn-s3-demo-bucket/sales/orders_by_day/' )
INSERT INTO writes each row to its partition and registers new partitions in the AWS Glue Data Catalog. To register partitions for data that another process wrote to Amazon S3, use ALTER TABLE ... ADD PARTITION or the glue_repair_table function. The following SQL statement registers one partition.
ALTER TABLE sales_db.orders_by_day ADD PARTITION (order_date = DATE '2026-10-01')
MSCK REPAIR TABLE is not supported. In its place, call glue_repair_table. It registers each key=value directory under the table location that is not yet a registered partition, and it returns one row for each partition that it registers. The following SQL statement registers the partition directories under the table location.
CALL glue_repair_table('sales_db.orders_by_day')
To also find registered partitions whose location under the table location holds no files, add missing := true. The result then has a status column, which is added for a partition that the call registers and missing for a partition without files. The function does not remove the missing partitions.
To list partitions in place of SHOW PARTITIONS, query the glue_partitions table function.
SELECT * FROM glue_partitions('awsdatacatalog.sales_db.orders_by_day')
DuckDB cannot read tables that use partition projection. To query such a table, set projection.enabled to false and register its partitions in the AWS Glue Data Catalog.
To partition an Iceberg table, use PARTITIONED BY with columns or with the transforms year, month, day, hour, bucket, and truncate, such as PARTITIONED BY (day(order_ts)). You cannot add, drop, or rename the partitions of an Iceberg table.
For more information, see the following topics:
Work with Apache Iceberg tables
DuckDB reads and writes the Apache Iceberg tables in your AWS Glue Data Catalog. Keep the following in mind when you work with Iceberg tables:
-
DuckDB reads format version 1, and it reads and writes format versions 2 and 3. Athena engine version 3 cannot read format version 3 tables, and you cannot downgrade a table. Keep tables that Athena engine version 3 reads at format version 2.
-
Data files must be Parquet. DuckDB writes Parquet even if
write.format.defaultis set toorcoravro. -
You can change rows with
UPDATEandDELETE.UPDATEfails on a table whosewrite.update.modeproperty iscopy-on-write. To update the table, first runALTER TABLE sales_db.orders SET ('write.update.mode' = 'merge-on-read'). -
MERGE INTOis not supported in this Preview. -
To read an earlier snapshot, add an
AT (VERSION => snapshot_id)orAT (TIMESTAMP => timestamp)clause. Branches and tags are not supported. To list snapshot IDs, use theiceberg_snapshotsfunction.
For more information, see the following topics:
Work with Amazon S3 Tables
Each table bucket appears as a catalog named s3tablescatalog/<table-bucket>, and each namespace is a database. The following SQL query reads a table in a table bucket.
SELECT * FROM "s3tablescatalog/amzn-s3-demo-table-bucket".tutorial_ns.daily_orders LIMIT 10
Keep the following in mind when you work with S3 Tables:
-
Reads,
CREATE TABLE, CTAS,INSERT,UPDATE, andDELETEare supported in this Preview.MERGE INTOandTRUNCATEare not. -
When you create a table in a table bucket, omit
location. -
DROP TABLEdeletes the table's data. -
Integrate your table buckets with AWS analytics services by using IAM access control. IAM access control is the default. If the integration uses AWS Lake Formation access control, statements on the tables fail. For more information, see Security and permissions.
Inspect databases and tables
The following table lists the statements and functions that show catalog metadata.
| To see | Use |
|---|---|
| Databases | SHOW SCHEMAS, or the duckdb_schemas() function |
| Tables in a database | SHOW TABLES FROM sales_db, or the duckdb_tables() function |
| Columns and data types | DESCRIBE sales_db.orders |
| Databases, tables, and columns as views | The information_schema views schemata, tables, and columns |
| Table location, SerDe, parameters, and partition keys | The glue_get_table_response function |
| Hive partitions | The glue_partitions function |
| Location, SerDe, and parameters of one Hive partition | The glue_get_partition_response function |
| Iceberg table properties | The iceberg_table_properties function |
| Iceberg snapshots | The iceberg_snapshots function |
| Iceberg partition specs | The iceberg_partition_specs function |
The following SQL query reads the AWS Glue metadata of a Hive table.
SELECT * EXCLUDE (response) FROM glue_get_table_response('awsdatacatalog.sales_db.orders_parquet')
SHOW CREATE TABLE, SHOW COLUMNS, SHOW PARTITIONS, SHOW TBLPROPERTIES, DESCRIBE EXTENDED, and DESCRIBE FORMATTED are not supported. In place of DESCRIBE FORMATTED ... PARTITION (...), use glue_get_partition_response, such as glue_get_partition_response('sales_db.orders_by_day', {order_date: DATE '2026-10-01'}). For more information, see DESCRIBE, SHOW, SUMMARIZE, and EXPLAIN statements in DuckDB and AWS Glue Data Catalog functions in DuckDB.
Read and write files by Amazon S3 path
DuckDB can read files in Amazon S3 without a table in the catalog, and it can write query results to Amazon S3 with COPY (SELECT ...) TO. Use COPY (SELECT ...) TO in place of the Athena engine version 3 UNLOAD statement. The following SQL query reads Parquet files directly.
SELECT * FROM read_parquet('s3://amzn-s3-demo-bucket/raw/events/*.parquet')
The following SQL statement writes a query result to a Parquet file.
COPY ( SELECT region, sum(amount) AS revenue FROM sales_db.orders_parquet GROUP BY region ) TO 's3://amzn-s3-demo-bucket/exports/revenue.parquet' (FORMAT parquet)
Reads and writes by Amazon S3 path do not go through the AWS Glue Data Catalog. Table permissions in AWS Glue or AWS Lake Formation do not limit them. Only the IAM permissions of the principal that runs the query for Amazon S3 limit them. This is true even if your policies allow Amazon S3 access only for requests that Athena makes. This includes policies that use the aws:CalledVia condition key. For more information, see Security and permissions.
For more information about the file reading functions and their options, see Read files directly from Amazon S3.
Share tables with Athena engine version 3 and other engines
Both engines use the AWS Glue Data Catalog, so a table that one engine creates is visible to the other. For tables that more than one engine reads, follow these rules:
-
Use Parquet for Hive tables.
-
Keep Iceberg tables at format version 2.
-
Do not use
TIMESTAMP WITH TIME ZONE,TIME,UUID, orVARIANTcolumns in Hive tables. -
Do not set
write.format.defaulttoorcoravroon an Iceberg table. -
Query a view from the engine that created it.
For more information, see Sharing tables with engine version 3 and other engines.
Differences from Athena engine version 3
The following table lists the catalog differences between Athena engine version 3 and DuckDB.
| Area | Athena engine version 3 | DuckDB |
|---|---|---|
| Create, drop, and list databases | CREATE DATABASE, DROP DATABASE, SHOW DATABASES |
CREATE SCHEMA, DROP SCHEMA, SHOW SCHEMAS |
| Database metadata | COMMENT, LOCATION, WITH DBPROPERTIES |
WITH (key = value, ...) |
| Create a Hive table | CREATE EXTERNAL TABLE ... ROW FORMAT ... STORED AS ... LOCATION ... TBLPROPERTIES |
CREATE TABLE ... WITH (type = 'HIVE', format = ..., location = ...) |
| Partition columns | Declared with types in PARTITIONED BY only |
Listed in the column list, and named without types in PARTITIONED BY |
| Register partitions | MSCK REPAIR TABLE, ALTER TABLE ADD PARTITION |
CALL glue_repair_table(...), ALTER TABLE ADD PARTITION |
| List partitions | SHOW PARTITIONS |
glue_partitions(...) |
| Table details | SHOW CREATE TABLE, DESCRIBE FORMATTED, SHOW TBLPROPERTIES |
DESCRIBE, glue_get_table_response(...), glue_get_partition_response(...), iceberg_table_properties(...) |
| Set the default database | Query execution context | Query execution context (USE is not supported) |
| Export results | UNLOAD |
COPY (SELECT ...) TO |
| Read files without a table | Not supported | read_parquet, read_csv, read_json |
DROP TABLE on an Iceberg table |
Deletes data and metadata files | Leaves data and metadata files in Amazon S3 |
| Table formats | Hive, Iceberg, Delta Lake, Hudi | Hive, Iceberg, S3 Tables |
MERGE INTO on Iceberg |
Supported | No |
OPTIMIZE, VACUUM |
Supported | No |
| Views over Iceberg tables | Supported | No |
| Cross-account catalogs and Lake Formation | Supported | No |
| Federated catalogs | Supported | No |
Considerations and limitations
Keep the following in mind when you work with the AWS Glue Data Catalog:
-
All catalogs that you query must be in your own account. This Preview does not support cross-account catalogs or AWS Lake Formation resource links.
-
DuckDB queries the AWS Glue Data Catalog in the workgroup's Region. It cannot read Amazon S3 buckets in other Regions.
-
This Preview does not support tables in Amazon S3 locations that are registered with AWS Lake Formation. This includes tables that grant permissions to
IAMAllowedPrincipals. Statements on these tables fail with an error that contains "is registered with Lake Formation." -
This Preview does not support federated catalogs (data source connectors).
-
You cannot create bucketed, Delta Lake, Hudi, or ORC tables.
-
Data that DuckDB writes to Amazon S3 uses the default encryption of the bucket. DuckDB does not apply workgroup encryption settings or the
encryption_optionandkms_keytable properties. -
DuckDB cannot read tables that use client-side encryption with AWS KMS (CSE-KMS).
-
A write that fails with a transient-error message may already have been applied. Check before you retry it. For more information, see Troubleshooting.