View a markdown version of this page

DESCRIBE, SHOW, SUMMARIZE, and EXPLAIN statements in DuckDB - Amazon Athena

DESCRIBE, SHOW, SUMMARIZE, and EXPLAIN statements in DuckDB

Use these statements to look at your tables and queries. DESCRIBE returns the columns and data types of a table or of the result of a query. SHOW TABLES lists the tables and views of a database. SUMMARIZE computes statistics for each column of a table or query result, such as the smallest and largest values and the percentage of NULL values. EXPLAIN returns the plan that DuckDB makes to run a query. You can also query the information_schema views that describe databases, tables, and columns.

None of these statements changes a table or the AWS Glue Data Catalog. You can use the result of DESCRIBE, SHOW TABLES, or SUMMARIZE in the FROM clause of a query, for example to filter or sort it. For more information about using these results in a query, see Use the result of DESCRIBE, SHOW TABLES, or SUMMARIZE in a query.

The examples use tables in a database named sales_db. The sales_parquet table is a Hive table in Parquet format that holds six orders. Its columns are order_id (INTEGER), customer (VARCHAR), region (VARCHAR), amount (DECIMAL(10,2)), and order_date (DATE). One of the orders has a NULL amount. The sales_csv table is a Hive table in CSV format that is partitioned by region. The orders_iceberg table is an Apache Iceberg table with the same columns as sales_parquet. The database also holds other tables, which appear in the results of the examples that list tables.

For more information about how these statements differ from the statements in Athena engine version 3, see SQL differences from Athena v3.

Synopsis

DESCRIBE [ TABLE ] table_name DESCRIBE query SHOW TABLES [ FROM [ catalog. ] database ] SUMMARIZE { table_name | query } EXPLAIN [ ( FORMAT json ) ] query SELECT select_list FROM information_schema.{ schemata | tables | columns } [ WHERE condition ]

DESCRIBE a table

DESCRIBE table_name returns one row for each column of a table, in the order of the table's columns. The column_name and column_type columns hold the name and the data type of each column, with DuckDB type names such as VARCHAR and DECIMAL(10,2). The null column is YES when the table column can hold NULL values. The key, default, and extra columns are NULL for Hive and Iceberg tables.

For a partitioned Hive table, the partition columns come after the other columns, as in the second example.

DESCRIBE TABLE table_name returns the same result. You can also describe a view. For more information about views, see Work with views.

Syntax

DESCRIBE [ TABLE ] table_name

In the syntax, replace each placeholder as follows:

table_name

The name of a table or view, as a one-part, two-part (database.table), or three-part (catalog.database.table) name. DuckDB takes a missing catalog or database from the query execution context. For more information about table names, see SQL reference.

Examples

The following SQL statement describes the sales_parquet table.

DESCRIBE sales_db.sales_parquet

The statement returns the following results.

column_name column_type null key default extra

order_id

INTEGER

YES

NULL

NULL

NULL

customer

VARCHAR

YES

NULL

NULL

NULL

region

VARCHAR

YES

NULL

NULL

NULL

amount

DECIMAL(10,2)

YES

NULL

NULL

NULL

order_date

DATE

YES

NULL

NULL

NULL

The following SQL statement describes sales_csv, a Hive table that is partitioned by region. The partition column, region, comes last.

DESCRIBE sales_db.sales_csv

The statement returns the following results.

column_name column_type null key default extra

order_id

INTEGER

YES

NULL

NULL

NULL

customer

VARCHAR

YES

NULL

NULL

NULL

amount

DOUBLE

YES

NULL

NULL

NULL

region

VARCHAR

YES

NULL

NULL

NULL

The following SQL statement describes the Iceberg table orders_iceberg. It uses the TABLE keyword and a three-part name that includes the catalog.

DESCRIBE TABLE awsdatacatalog.sales_db.orders_iceberg

The statement returns the following results.

column_name column_type null key default extra

order_id

INTEGER

YES

NULL

NULL

NULL

customer

VARCHAR

YES

NULL

NULL

NULL

region

VARCHAR

YES

NULL

NULL

NULL

amount

DECIMAL(10,2)

YES

NULL

NULL

NULL

order_date

DATE

YES

NULL

NULL

NULL

Considerations

DESCRIBE does not return the location, file format, or properties of a table. For a Hive table, call glue_get_table_response. For an Iceberg table, call iceberg_table_properties to see the properties in the table's Iceberg metadata. To find the current metadata file of an Iceberg table in Amazon S3, select parameters['metadata_location'] from glue_get_table_response. To see the file format of each data file of an Iceberg table, call iceberg_files. For more information about these functions, see glue_get_table_response function, iceberg_table_properties function, and iceberg_files function.

Differences from Athena engine version 3

Athena engine version 3 shows the details of a table with DESCRIBE EXTENDED and DESCRIBE FORMATTED. DuckDB does not support them. For a Hive table, call glue_get_table_response. For an Iceberg table, use DESCRIBE and call iceberg_table_properties.

Athena engine version 3 lists the columns of a table with SHOW COLUMNS. DuckDB does not support SHOW COLUMNS. Use DESCRIBE instead.

Athena engine version 3 lists the partitions of a table with SHOW PARTITIONS. DuckDB does not support SHOW PARTITIONS. To list the partitions of a Hive table, call glue_partitions. For more information about glue_partitions, see glue_partitions function.

Athena engine version 3 lists the properties of a table with SHOW TBLPROPERTIES. DuckDB does not support SHOW TBLPROPERTIES. For a Hive table, call glue_get_table_response, and for an Iceberg table, call iceberg_table_properties.

In Athena engine version 3, SHOW CREATE TABLE returns the CREATE TABLE statement for a table. DuckDB does not support SHOW CREATE TABLE. To see a CREATE TABLE statement for a table, select the sql column of duckdb_tables(). For more information about duckdb_tables(), see duckdb_tables function.

DESCRIBE a query

DESCRIBE query returns one row for each column of the result of a query, with the same columns as the result of DESCRIBE for a table. Use it to check the data type of an expression, or to see the columns and types of files in Amazon S3 before you create a table for them.

The query can read tables, read files with table functions such as read_parquet, or select literal values without a FROM clause, as in the examples.

Syntax

DESCRIBE query

In the syntax, replace each placeholder as follows:

query

A SELECT statement. For more information about SELECT, see SELECT statement in DuckDB.

Examples

The following SQL statement returns the data types of three expressions. The DECIMAL(10,2) column amount multiplied by 2 is a DECIMAL(18,2). The DATE column order_date plus INTERVAL 1 DAY is a TIMESTAMP.

DESCRIBE SELECT order_id, amount * 2 AS doubled, order_date + INTERVAL 1 DAY AS next_day FROM sales_db.sales_parquet

The statement returns the following results.

column_name column_type null key default extra

order_id

INTEGER

YES

NULL

NULL

NULL

doubled

DECIMAL(18,2)

YES

NULL

NULL

NULL

next_day

TIMESTAMP

YES

NULL

NULL

NULL

The following SQL statement returns the columns that read_parquet finds in the Parquet files of the sales_parquet table in Amazon S3. They are the columns of the table, with the same data types.

DESCRIBE SELECT * FROM read_parquet( 's3://amzn-s3-demo-bucket/tables/sales_parquet/*' )

The statement returns the following results.

column_name column_type null key default extra

order_id

INTEGER

YES

NULL

NULL

NULL

customer

VARCHAR

YES

NULL

NULL

NULL

region

VARCHAR

YES

NULL

NULL

NULL

amount

DECIMAL(10,2)

YES

NULL

NULL

NULL

order_date

DATE

YES

NULL

NULL

NULL

The following SQL statement returns the data types of five literals: an integer, a string, a list, a struct, and a date. The numbers 1.5 and 2.5 in the struct are DECIMAL(2,1) values.

DESCRIBE SELECT 42 AS answer, 'abc' AS label, [1, 2, 3] AS numbers, { 'x': 1.5, 'y': 2.5 } AS point, DATE '2026-10-01' AS day

The statement returns the following results.

column_name column_type null key default extra

answer

INTEGER

YES

NULL

NULL

NULL

label

VARCHAR

YES

NULL

NULL

NULL

numbers

INTEGER[]

YES

NULL

NULL

NULL

point

STRUCT(x DECIMAL(2,1), y DECIMAL(2,1))

YES

NULL

NULL

NULL

day

DATE

YES

NULL

NULL

NULL

SHOW TABLES

SHOW TABLES FROM database returns the names of the tables and views in a database, one row for each, sorted by name, in a column named name.

Without FROM, SHOW TABLES lists the tables and views of the database that the query execution context sets. For more information about the query execution context, see SQL reference.

To filter or sort the table names, use SHOW TABLES in the FROM clause of a query, or query duckdb_tables() or information_schema.tables. For more information about using SHOW TABLES in a query, see Use the result of DESCRIBE, SHOW TABLES, or SUMMARIZE in a query.

Syntax

SHOW TABLES [ FROM [ catalog. ] database ]

In the syntax, replace each placeholder as follows:

database

The database whose tables you want to list. You can enclose the name in double quotes.

catalog

The catalog that holds the database, such as awsdatacatalog. Without a catalog, DuckDB uses the catalog of the query execution context.

Examples

The following SQL statement lists the tables in the sales_db database.

SHOW TABLES FROM sales_db

The statement returns the following results.

name

columns_demo

location_demo

orders_iceberg

partition_demo

props_iceberg

sales_csv

sales_json

sales_parquet

Considerations

DuckDB calls a database a schema. To list databases, use SHOW SCHEMAS. To filter database names, query duckdb_schemas() or information_schema.schemata with a WHERE clause. For more information about information_schema.schemata, see information_schema views.

Differences from Athena engine version 3

Athena engine version 3 lists the tables of a database with SHOW TABLES IN database. In DuckDB, write SHOW TABLES FROM database.

In Athena engine version 3, SHOW TABLES can filter table names with a pattern. DuckDB does not support the LIKE and regular expression forms of SHOW TABLES. To filter table names, select from SHOW TABLES with a WHERE clause, or query duckdb_tables().

Athena engine version 3 returns the result of SHOW TABLES in a column named tab_name, without a header row. In DuckDB, the result is in a column named name, with a header row, like the result of a SELECT query. Update any client that reads the tab_name column or that does not expect a header row.

SUMMARIZE

SUMMARIZE computes statistics for each column of a table or of the result of a query, and returns one row for each column, in column order. Use it to explore the data in a table, for example to find the columns that have NULL values or to see the range of values in each column.

The result has 12 columns. The column_name and column_type columns hold the name and the data type of the summarized column. The min and max columns hold the smallest and the largest values. The approx_unique column holds an estimate of the number of distinct values. The avg and std columns hold the average and the standard deviation. The q25, q50, and q75 columns hold estimates of the 25th, 50th, and 75th percentiles. For a column whose type has no average, such as VARCHAR, the avg, std, q25, q50, and q75 columns are NULL. For a DATE column, avg is a timestamp and std is NULL. The count column holds the number of rows. The null_percentage column holds the percentage of the rows in which the column is NULL.

The min, max, avg, std, q25, q50, and q75 columns have the type VARCHAR, because each of them holds values from table columns of different types.

To compute the statistics, SUMMARIZE reads every row of the table or of the query result. To summarize some of the rows of a table, summarize a query that filters them, as in the second example.

Syntax

SUMMARIZE table_name SUMMARIZE query

In the syntax, replace each placeholder as follows:

table_name

The name of a table, in any of the forms that DESCRIBE accepts.

query

A SELECT statement whose result you want to summarize.

Examples

The following SQL statement summarizes every column of the sales_parquet table. One of the six values of amount is NULL, so the null_percentage of amount is 16.67.

SUMMARIZE sales_db.sales_parquet

The statement returns the following results.

column_name column_type min max approx_unique avg std q25 q50 q75 count null_percentage

order_id

INTEGER

1

6

6

3.5

1.8708286933869707

2

4

5

6

0.00

customer

VARCHAR

alice

frank

6

NULL

NULL

NULL

NULL

NULL

6

0.00

region

VARCHAR

east

west

3

NULL

NULL

NULL

NULL

NULL

6

0.00

amount

DECIMAL(10,2)

18.75

310.00

5

113.3

116.40170209236634

36.38

75.00

167.88

6

16.67

order_date

DATE

2026-10-01

2026-10-04

4

2026-10-02 08:00:00

NULL

2026-10-01

2026-10-02

2026-10-03

6

0.00

The following SQL statement summarizes the customer and amount columns of the three orders in the east region. One of the three amounts is NULL, so the null_percentage of amount is 33.33.

SUMMARIZE SELECT customer, amount FROM sales_db.sales_parquet WHERE region = 'east'

The statement returns the following results.

column_name column_type min max approx_unique avg std q25 q50 q75 count null_percentage

customer

VARCHAR

alice

frank

3

NULL

NULL

NULL

NULL

NULL

3

0.00

amount

DECIMAL(10,2)

42.25

120.50

2

81.375

55.33110562784734

42.25

81.38

120.50

3

33.33

The following SQL statement summarizes a VALUES list. Each of the two columns has one NULL value in four rows, so the null_percentage of each column is 25.00.

SUMMARIZE SELECT * FROM ( VALUES (1, 'a'), (2, NULL), (3, 'c'), (NULL, 'c') ) AS t(id, code)

The statement returns the following results.

column_name column_type min max approx_unique avg std q25 q50 q75 count null_percentage

id

INTEGER

1

3

3

2.0

1.0

1

2

3

4

25.00

code

VARCHAR

a

c

2

NULL

NULL

NULL

NULL

NULL

4

25.00

Considerations

The approx_unique, q25, q50, and q75 columns hold estimates, so they can differ from the exact values. For exact values, use count(DISTINCT column) and quantile_cont in a query. For more information about quantile_cont, see quantile_cont function.

Use the result of DESCRIBE, SHOW TABLES, or SUMMARIZE in a query

You can put DESCRIBE, SHOW TABLES, or SUMMARIZE in parentheses in the FROM clause of a query, like a subquery. The query can then filter and sort the rows of the result, and choose and rename its columns.

Use this form to filter table names with a pattern, or to find the columns of a table that have a given type. You can also use it to read only some of the statistics that SUMMARIZE returns. To fix the order of the rows, add an ORDER BY clause, as in the examples.

Syntax

SELECT select_list FROM ( statement ) [ WHERE condition ] [ ORDER BY expression [, ...] ] statement: { DESCRIBE table_name | SHOW TABLES FROM database | SUMMARIZE table_name }

Examples

The following SQL query lists the VARCHAR columns of the sales_csv table.

SELECT column_name, column_type FROM (DESCRIBE sales_db.sales_csv) WHERE column_type = 'VARCHAR' ORDER BY column_name

The query returns the following results.

column_name column_type

customer

VARCHAR

region

VARCHAR

The following SQL query lists the tables in sales_db whose names start with sales, in a column renamed to table_name.

SELECT name AS table_name FROM (SHOW TABLES FROM sales_db) WHERE name LIKE 'sales%' ORDER BY table_name

The query returns the following results.

table_name

sales_csv

sales_json

sales_parquet

The following SQL query returns the smallest value, the largest value, and the percentage of NULL values of each column of sales_parquet, sorted by column name.

SELECT column_name, min AS min_value, max AS max_value, null_percentage FROM (SUMMARIZE sales_db.sales_parquet) ORDER BY column_name

The query returns the following results.

column_name min_value max_value null_percentage

amount

18.75

310.00

16.67

customer

alice

frank

0.00

order_date

2026-10-01

2026-10-04

0.00

order_id

1

6

0.00

region

east

west

0.00

EXPLAIN

EXPLAIN query returns the plan that DuckDB makes to run a query. The plan lists the operators that read and process the rows, such as scans, filters, and aggregates. Most operators show an estimate of the number of rows that they return. The result is one row, with physical_plan in the explain_key column and the plan in the explain_value column. EXPLAIN does not return the rows of the query.

By default, the plan is text that draws each operator as a box with line-drawing characters. With (FORMAT json), the plan is a JSON array of operators, each with its name, its children, and details such as the row estimate in extra_info. Use the JSON format to read a plan in a program.

Syntax

EXPLAIN query EXPLAIN ( FORMAT json ) query

In the syntax, replace each placeholder as follows:

query

The query to plan, such as a SELECT statement.

Examples

The following SQL statement returns the plan, as JSON, for a query that counts the orders with an amount greater than 50. A HIVE_SCAN operator reads the table and applies the filter amount > 50.00, and an UNGROUPED_AGGREGATE operator counts the rows that the scan returns.

EXPLAIN (FORMAT json) SELECT count(*) AS orders FROM sales_db.sales_parquet WHERE amount > 50

The statement returns the following result.

explain_key explain_value

physical_plan

[ { "name": "UNGROUPED_AGGREGATE", "children": [ { "name": "HIVE_SCAN", "children": [], "extra_info": { "Function": "HIVE_SCAN", "Projections": "", "Filters": "(amount > 50.00)", "Estimated Cardinality": "1" } } ], "extra_info": { "Aggregates": "count_star()", "Estimated Cardinality": "1" } } ]

The following SQL statement returns the plan, as JSON, for a query that filters a VALUES list and doubles the values that are left. A COLUMN_DATA_SCAN operator reads the VALUES list, a FILTER operator applies x > 1, and a PROJECTION operator returns doubled.

EXPLAIN (FORMAT json) SELECT x * 2 AS doubled FROM (VALUES (1), (2), (3)) AS t(x) WHERE x > 1

The statement returns the following result.

explain_key explain_value

physical_plan

[ { "name": "PROJECTION", "children": [ { "name": "FILTER", "children": [ { "name": "COLUMN_DATA_SCAN", "children": [], "extra_info": { "Estimated Cardinality": "3" } } ], "extra_info": { "Expression": "(x > 1)", "Estimated Cardinality": "1" } } ], "extra_info": { "Projections": "doubled", "Estimated Cardinality": "1" } } ]

Considerations

You cannot use EXPLAIN in the FROM clause of a query.

EXPLAIN accepts the FORMAT option but not the TYPE option, such as (TYPE DISTRIBUTED).

information_schema views

You can query three standard SQL views. The information_schema.schemata view describes databases. The information_schema.tables view describes tables and views. The information_schema.columns view describes the columns of tables. Use these views when a tool or a query expects the standard column names. Filter on the database name, as in the examples, to get only the rows of the databases that you want.

DuckDB calls a database a schema. In these views, the catalog, such as awsdatacatalog, is in the catalog_name or table_catalog column, and the AWS Glue database is in the schema_name or table_schema column. In information_schema.tables, the table_type of Hive and Iceberg tables is BASE TABLE, and the table_type of views is VIEW. To list views, see List views.

In information_schema.columns, the ordinal_position value is the position of the column in its table, starting at 1. The data_type value is the data type of the column. The is_nullable value is YES when the column can hold NULL values. Filter on table_schema and table_name to get the columns of one table.

Syntax

SELECT select_list FROM information_schema.schemata [ WHERE condition ] SELECT select_list FROM information_schema.tables [ WHERE condition ] SELECT select_list FROM information_schema.columns [ WHERE condition ]

Examples

The following SQL query returns the catalog and the name of the sales_db database.

SELECT catalog_name, schema_name FROM information_schema.schemata WHERE schema_name = 'sales_db'

The query returns the following result.

catalog_name schema_name

awsdatacatalog

sales_db

The following SQL query lists the tables in sales_db whose names start with sales, with the type of each. Each of them is a BASE TABLE.

SELECT table_name, table_type FROM information_schema.tables WHERE table_schema = 'sales_db' AND table_name LIKE 'sales%' ORDER BY table_name

The query returns the following results.

table_name table_type

sales_csv

BASE TABLE

sales_json

BASE TABLE

sales_parquet

BASE TABLE

The following SQL query lists the columns of the sales_csv table in table order, with the data type of each and whether it can hold NULL values.

SELECT column_name, data_type, is_nullable FROM information_schema.columns WHERE table_schema = 'sales_db' AND table_name = 'sales_csv' ORDER BY ordinal_position

The query returns the following results.

column_name data_type is_nullable

order_id

INTEGER

YES

customer

VARCHAR

YES

amount

DOUBLE

YES

region

VARCHAR

YES

Considerations

The information_schema views about constraints, such as table_constraints and key_column_usage, are not available.

You cannot list views with the information_schema.views view, the pg_catalog.pg_views view, or the duckdb_views function. For more information about views, see Work with views.