

# File metadata functions

Use these functions to read the metadata in the footers of Parquet files and the headers of Avro files, without reading the data.

The metadata includes schemas, row counts, column statistics, page indexes, and Bloom filters.

For a description of the sample tables and files that the examples on this page use, see [Table functions in DuckDB](duckdb-functions-table.md).

## `avro_metadata` function
<a name="athena-duckdb-functions-table-avro-metadata"></a>

Returns one row for each key-value pair in the header of an Avro object container file. The key `avro.schema` holds the schema of the file's records as a JSON string, and the key `avro.codec`, when the file has it, holds the name of the compression codec. The program that wrote the file can add other keys.

The function reads the header only. To read the records, use the [`read_avro` function](duckdb-functions-table-file-readers.md#athena-duckdb-functions-table-read-avro). To read parts of the schema, use JSON functions on the `value` column of the `avro.schema` row, as in the second example.

### Syntax
<a name="athena-duckdb-functions-table-avro-metadata-syntax"></a>

```sql
avro_metadata({{path}})
```

### Arguments
<a name="athena-duckdb-functions-table-avro-metadata-arguments"></a>

The `avro_metadata` function takes the following argument:

**{{path}}**  
The Amazon S3 path of one Avro file, as a `VARCHAR` value.

### Return type
<a name="athena-duckdb-functions-table-avro-metadata-return-type"></a>

A table with the columns `key` (`VARCHAR`) and `value` (`VARCHAR`).

### Examples
<a name="athena-duckdb-functions-table-avro-metadata-examples"></a>

The following SQL query lists the header keys of an Avro file. The file is a manifest list of the Iceberg table `orders_iceberg`. Iceberg stores its manifest lists and manifests as Avro files.

```sql
SELECT key
FROM avro_metadata(
    's3://amzn-s3-demo-bucket/tables/orders_iceberg/metadata/snap-1294122691170353594-d7066457-4da0-4374-822e-7f7616a4303a.avro'
)
ORDER BY key
```

The query returns the following results.


| key | 
| --- | 
| `avro.codec` | 
| `avro.schema` | 

The following SQL query reads the name of the record type and its number of fields from the schema of the same file, with JSON functions.

```sql
SELECT
    json_extract_string(value, '$.name') AS record_name,
    json_array_length(value, '$.fields') AS field_count
FROM avro_metadata(
    's3://amzn-s3-demo-bucket/tables/orders_iceberg/metadata/snap-1294122691170353594-d7066457-4da0-4374-822e-7f7616a4303a.avro'
)
WHERE key = 'avro.schema'
```

The query returns the following result.


| record\_name | field\_count | 
| --- | --- | 
| `manifest_file` | `14` | 

### Considerations
<a name="athena-duckdb-functions-table-avro-metadata-considerations"></a>

`avro_metadata` reads exactly one file. It does not expand wildcards such as `*`, and it does not accept a list of paths. To read the metadata of several files, call it once for each file.

## `parquet_bloom_probe` function
<a name="athena-duckdb-functions-table-parquet-bloom-probe"></a>

Returns one row for each row group of each Parquet file in `path`. The `bloom_filter_excludes` column is `true` when the Bloom filter of `column_name` in that row group shows that the row group does not contain `value`. It is `false` when the row group might contain the value, which includes a row group in which the column has no Bloom filter.

A Bloom filter can report a value that is not there, but it never misses a value that is there. A `true` result is therefore certain, and a `false` result means only that you must read the row group to know. Parquet writers often store Bloom filters for only some columns, or for none. To see which column chunks have a Bloom filter, check `bloom_filter_offset` in the result of `parquet_metadata`.

### Syntax
<a name="athena-duckdb-functions-table-parquet-bloom-probe-syntax"></a>

```sql
parquet_bloom_probe({{path}}, {{column_name}}, {{value}})
```

### Arguments
<a name="athena-duckdb-functions-table-parquet-bloom-probe-arguments"></a>

The `parquet_bloom_probe` function takes the following arguments:

**{{path}}**  
The Amazon S3 location of the Parquet files: a `VARCHAR` path that can contain wildcards, such as `*`, or a list of such paths (`VARCHAR[]`).

**{{column\_name}}**  
The name of the column to probe, as a `VARCHAR` value.

**{{value}}**  
The value to look for. The function converts it to the type of the column, so `3` and `'3'` both work for an integer column.

### Return type
<a name="athena-duckdb-functions-table-parquet-bloom-probe-return-type"></a>

A table with one row per row group and the columns `file_name` (`VARCHAR`), `row_group_id` (`BIGINT`), and `bloom_filter_excludes` (`BOOLEAN`).

### Examples
<a name="athena-duckdb-functions-table-parquet-bloom-probe-examples"></a>

The following SQL query checks each row group of the Parquet files of `sales_parquet` for the customer name `zed`, which is not in the data. The result is `false` because the `customer` column has no Bloom filter in these files, as the second example shows.

```sql
SELECT row_group_id, bloom_filter_excludes
FROM parquet_bloom_probe(
    's3://amzn-s3-demo-bucket/tables/sales_parquet/*',
    'customer', 'zed'
)
ORDER BY row_group_id
```

The query returns the following result.


| row\_group\_id | bloom\_filter\_excludes | 
| --- | --- | 
| `0` | `false` | 

The following SQL query uses `parquet_metadata` to check which column chunks of the same files have a Bloom filter. For a column chunk without one, `parquet_bloom_probe` always returns `false`.

```sql
SELECT
    path_in_schema AS column_name,
    bloom_filter_offset IS NOT NULL AS has_bloom_filter
FROM parquet_metadata(
    's3://amzn-s3-demo-bucket/tables/sales_parquet/*'
)
ORDER BY column_id
```

The query returns the following results.


| column\_name | has\_bloom\_filter | 
| --- | --- | 
| `order_id` | `false` | 
| `customer` | `false` | 
| `region` | `false` | 
| `amount` | `false` | 
| `order_date` | `false` | 

### Considerations
<a name="athena-duckdb-functions-table-parquet-bloom-probe-considerations"></a>

The query fails if a file has no column named `column_name`, if `value` cannot be converted to the type of the column, or if `column_name` or `value` is `NULL`.

## `parquet_file_metadata` function
<a name="athena-duckdb-functions-table-parquet-file-metadata"></a>

Returns one row for each Parquet file in `path`, with the metadata in the file's footer. The row gives the number of rows and row groups, the name and version of the program that wrote the file (`created_by`), and the Parquet format version. It also gives the size of the file and of its footer in bytes, the sort order of each column's statistics, and the encryption details of an encrypted file.

For the metadata of each column chunk, use the [`parquet_metadata` function](#athena-duckdb-functions-table-parquet-metadata). For the schema, use the [`parquet_schema` function](#athena-duckdb-functions-table-parquet-schema).

### Syntax
<a name="athena-duckdb-functions-table-parquet-file-metadata-syntax"></a>

```sql
parquet_file_metadata({{path}})
```

### Arguments
<a name="athena-duckdb-functions-table-parquet-file-metadata-arguments"></a>

The `parquet_file_metadata` function takes the following argument:

**{{path}}**  
The Amazon S3 location of the Parquet files: a `VARCHAR` path that can contain wildcards, such as `*`, or a list of such paths (`VARCHAR[]`).

### Return type
<a name="athena-duckdb-functions-table-parquet-file-metadata-return-type"></a>

A table with one row per file. The `VARCHAR` columns are `file_name`, `created_by`, `encryption_algorithm`, and `footer_signing_key_metadata`. The `BIGINT` columns are `num_rows`, `num_row_groups`, and `format_version`. The `UBIGINT` columns are `file_size_bytes` and `footer_size`, and the `column_orders` column is a `VARCHAR[]`.

### Examples
<a name="athena-duckdb-functions-table-parquet-file-metadata-examples"></a>

The following SQL query returns the number of rows and row groups in the Parquet files of `sales_parquet`.

```sql
SELECT num_rows, num_row_groups
FROM parquet_file_metadata(
    's3://amzn-s3-demo-bucket/tables/sales_parquet/*'
)
```

The query returns the following result.


| num\_rows | num\_row\_groups | 
| --- | --- | 
| `6` | `1` | 

The following SQL query passes a list of two files, the data files of the Iceberg table `orders_iceberg`, and adds up their rows and sizes.

```sql
SELECT
    count(*) AS files,
    sum(num_rows) AS total_rows,
    sum(file_size_bytes) AS total_bytes
FROM parquet_file_metadata([
    's3://amzn-s3-demo-bucket/tables/orders_iceberg/data/01a20c06-c637-7eb5-bfd6-5b178259ba76.parquet',
    's3://amzn-s3-demo-bucket/tables/orders_iceberg/data/01a20c06-d05e-7731-9cf5-521ecaed9e3a.parquet'
])
```

The query returns the following result.


| files | total\_rows | total\_bytes | 
| --- | --- | --- | 
| `2` | `3` | `1609` | 

## `parquet_full_metadata` function
<a name="athena-duckdb-functions-table-parquet-full-metadata"></a>

Returns one row for each Parquet file in `path`. The row has four columns, named after the other Parquet metadata functions: `parquet_file_metadata`, `parquet_metadata`, `parquet_schema`, and `parquet_kv_metadata`. Each column is a list of `STRUCT` values, one for each row that the function of the same name returns for the file.

Use `parquet_full_metadata` to get all of a file's metadata in one call. To work with one kind of metadata, query the function for that kind, which returns the metadata as rows and columns instead of as a list of `STRUCT` values.

### Syntax
<a name="athena-duckdb-functions-table-parquet-full-metadata-syntax"></a>

```sql
parquet_full_metadata({{path}})
```

### Arguments
<a name="athena-duckdb-functions-table-parquet-full-metadata-arguments"></a>

The `parquet_full_metadata` function takes the following argument:

**{{path}}**  
The Amazon S3 location of the Parquet files: a `VARCHAR` path that can contain wildcards, such as `*`, or a list of such paths (`VARCHAR[]`).

### Return type
<a name="athena-duckdb-functions-table-parquet-full-metadata-return-type"></a>

A table with one row per file and the columns `parquet_file_metadata`, `parquet_metadata`, `parquet_schema`, and `parquet_kv_metadata`. Each column is a list of `STRUCT` values whose fields are the columns that the function of the same name returns.

### Examples
<a name="athena-duckdb-functions-table-parquet-full-metadata-examples"></a>

The following SQL query counts the column chunks and the schema elements of the Parquet file of `sales_parquet`, and reads its number of rows. The schema has six elements: the root and the five columns.

```sql
SELECT
    len(parquet_metadata) AS column_chunks,
    len(parquet_schema) AS schema_elements,
    parquet_file_metadata[1].num_rows AS num_rows
FROM parquet_full_metadata(
    's3://amzn-s3-demo-bucket/tables/sales_parquet/*'
)
```

The query returns the following result.


| column\_chunks | schema\_elements | num\_rows | 
| --- | --- | --- | 
| `5` | `6` | `6` | 

The following SQL query reads the data files of the Iceberg table `orders_iceberg`, and returns one row for each file.

```sql
SELECT
    parquet_file_metadata[1].num_rows AS num_rows,
    len(parquet_metadata) AS column_chunks
FROM parquet_full_metadata(
    's3://amzn-s3-demo-bucket/tables/orders_iceberg/data/*.parquet'
)
ORDER BY num_rows
```

The query returns the following results.


| num\_rows | column\_chunks | 
| --- | --- | 
| `1` | `5` | 
| `2` | `5` | 

## `parquet_kv_metadata` function
<a name="athena-duckdb-functions-table-parquet-kv-metadata"></a>

Returns one row for each key-value pair in the footer of each Parquet file in `path`. The program that writes a Parquet file can store its own metadata there, such as the schema of the data in another format. A file without key-value metadata adds no rows.

`key` and `value` are `BLOB` values. To read them as text, use the [`decode` function](duckdb-functions-binary-blobs-and-encoding.md#athena-duckdb-functions-binary-decode), as in `decode(key)`.

### Syntax
<a name="athena-duckdb-functions-table-parquet-kv-metadata-syntax"></a>

```sql
parquet_kv_metadata({{path}})
```

### Arguments
<a name="athena-duckdb-functions-table-parquet-kv-metadata-arguments"></a>

The `parquet_kv_metadata` function takes the following argument:

**{{path}}**  
The Amazon S3 location of the Parquet files: a `VARCHAR` path that can contain wildcards, such as `*`, or a list of such paths (`VARCHAR[]`).

### Return type
<a name="athena-duckdb-functions-table-parquet-kv-metadata-return-type"></a>

A table with one row per key-value pair and the columns `file_name` (`VARCHAR`), `key` (`BLOB`), and `value` (`BLOB`).

### Examples
<a name="athena-duckdb-functions-table-parquet-kv-metadata-examples"></a>

The following SQL query counts the key-value pairs in the footers of the Parquet files of `sales_parquet`. The count is `0` because the program that wrote these files stored no key-value metadata.

```sql
SELECT count(*) AS entries
FROM parquet_kv_metadata(
    's3://amzn-s3-demo-bucket/tables/sales_parquet/*'
)
```

The query returns the following result.


| entries | 
| --- | 
| `0` | 

### Considerations
<a name="athena-duckdb-functions-table-parquet-kv-metadata-considerations"></a>

`decode` fails on bytes that are not valid UTF-8 text. For a value that might hold binary data, use `octet_length(value)` to get its size, or `try(decode(value))` to get `NULL` in place of an error.

## `parquet_metadata` function
<a name="athena-duckdb-functions-table-parquet-metadata"></a>

Returns one row for each column chunk of each row group of each Parquet file in `path`. A row group holds a set of rows, and a column chunk holds the values of one column in one row group. Each row gives the row group's ID and number of rows, and the column's path in the schema and its Parquet physical type. It also gives the statistics that the writer stored (`stats_min_value`, `stats_max_value`, and `stats_null_count`) and the compression codec and encodings. Other columns give the offsets and sizes of the column chunk in the file.

Use `parquet_metadata` to check the statistics, compression, and layout of a file without reading its data. For file-level metadata, use the [`parquet_file_metadata` function](#athena-duckdb-functions-table-parquet-file-metadata).

### Syntax
<a name="athena-duckdb-functions-table-parquet-metadata-syntax"></a>

```sql
parquet_metadata({{path}})
```

### Arguments
<a name="athena-duckdb-functions-table-parquet-metadata-arguments"></a>

The `parquet_metadata` function takes the following argument:

**{{path}}**  
The Amazon S3 location of the Parquet files: a `VARCHAR` path that can contain wildcards, such as `*`, or a list of such paths (`VARCHAR[]`).

### Return type
<a name="athena-duckdb-functions-table-parquet-metadata-return-type"></a>

A table with one row per column chunk. The `VARCHAR` columns are `file_name`, `path_in_schema`, `type`, `stats_min`, `stats_max`, `stats_min_value`, `stats_max_value`, `compression`, and `encodings`. The `BIGINT` columns are `row_group_id`, `row_group_num_rows`, `row_group_num_columns`, `row_group_bytes`, `row_group_compressed_bytes`, `column_id`, `file_offset`, `num_values`, `stats_null_count`, `stats_distinct_count`, `stats_nan_count`, `index_page_offset`, `dictionary_page_offset`, `data_page_offset`, `total_compressed_size`, `total_uncompressed_size`, `bloom_filter_offset`, `bloom_filter_length`, `column_index_offset`, `column_index_length`, `offset_index_offset`, and `offset_index_length`. The `min_is_exact` and `max_is_exact` columns are `BOOLEAN`, and the `key_value_metadata` column is a `MAP(BLOB, BLOB)`. The `geo_bbox` column is a `STRUCT` of `DOUBLE` bounds, and the `geo_types` column is a `VARCHAR[]`. The `encoding_stats` column is a `STRUCT(page_type VARCHAR, "encoding" VARCHAR, count INTEGER)[]`.

### Examples
<a name="athena-duckdb-functions-table-parquet-metadata-examples"></a>

The following SQL query returns the minimum, maximum, and number of `NULL` values that the Parquet file of `sales_parquet` stores for each column.

```sql
SELECT
    path_in_schema AS column_name,
    stats_min_value AS min_value,
    stats_max_value AS max_value,
    stats_null_count AS null_count
FROM parquet_metadata(
    's3://amzn-s3-demo-bucket/tables/sales_parquet/*'
)
ORDER BY column_id
```

The query returns the following results.


| column\_name | min\_value | max\_value | null\_count | 
| --- | --- | --- | --- | 
| `order_id` | `1` | `6` | `0` | 
| `customer` | `alice` | `frank` | `0` | 
| `region` | `east` | `west` | `0` | 
| `amount` | `18.75` | `310.00` | `1` | 
| `order_date` | `2026-10-01` | `2026-10-04` | `0` | 

The following SQL query returns the number of rows and the range of `customer` values in each data file of the Iceberg table `orders_iceberg`.

```sql
SELECT
    row_group_num_rows AS num_rows,
    stats_min_value AS min_customer,
    stats_max_value AS max_customer
FROM parquet_metadata(
    's3://amzn-s3-demo-bucket/tables/orders_iceberg/data/*.parquet'
)
WHERE path_in_schema = 'customer'
ORDER BY num_rows
```

The query returns the following results.


| num\_rows | min\_customer | max\_customer | 
| --- | --- | --- | 
| `1` | `carol` | `carol` | 
| `2` | `alice` | `bob` | 

### Considerations
<a name="athena-duckdb-functions-table-parquet-metadata-considerations"></a>

The minimum and maximum statistics (`stats_min`, `stats_max`, `stats_min_value`, and `stats_max_value`) are text (`VARCHAR`), whatever the type of the column. To compare one as a number or a date, cast it to that type.

`row_group_id` and `column_id` start at `0`.

## `parquet_page_index` function
<a name="athena-duckdb-functions-table-parquet-page-index"></a>

Returns one row for each data page of each column chunk that has a page index, in each Parquet file in `path`. The page index is an optional part of a Parquet file. For each data page, it records the page's offset and compressed size, and the index of its first row and its number of rows. It also records whether the page holds only `NULL` values, its minimum and maximum, and its number of `NULL` values.

A file without a page index adds no rows. To see whether a column chunk has a page index, check `column_index_offset` and `offset_index_offset` in the result of `parquet_metadata`.

### Syntax
<a name="athena-duckdb-functions-table-parquet-page-index-syntax"></a>

```sql
parquet_page_index({{path}})
```

### Arguments
<a name="athena-duckdb-functions-table-parquet-page-index-arguments"></a>

The `parquet_page_index` function takes the following argument:

**{{path}}**  
The Amazon S3 location of the Parquet files: a `VARCHAR` path that can contain wildcards, such as `*`, or a list of such paths (`VARCHAR[]`).

### Return type
<a name="athena-duckdb-functions-table-parquet-page-index-return-type"></a>

A table with one row per data page. The `VARCHAR` columns are `file_name`, `path_in_schema`, `min_value`, `max_value`, and `boundary_order`. The `BIGINT` columns are `row_group_id`, `column_id`, `page_id`, `page_offset`, `compressed_page_size`, `first_row_index`, `num_rows`, and `null_count`. The `null_page` column is a `BOOLEAN`.

### Examples
<a name="athena-duckdb-functions-table-parquet-page-index-examples"></a>

The following SQL query counts the page index entries in the Parquet files of `sales_parquet`. The count is `0` because these files have no page index, as the second example shows.

```sql
SELECT count(*) AS pages
FROM parquet_page_index(
    's3://amzn-s3-demo-bucket/tables/sales_parquet/*'
)
```

The query returns the following result.


| pages | 
| --- | 
| `0` | 

The following SQL query uses `parquet_metadata` to check which column chunks of the same files have the two parts of a page index, the column index and the offset index.

```sql
SELECT
    path_in_schema AS column_name,
    column_index_offset IS NOT NULL AS has_column_index,
    offset_index_offset IS NOT NULL AS has_offset_index
FROM parquet_metadata(
    's3://amzn-s3-demo-bucket/tables/sales_parquet/*'
)
ORDER BY column_id
```

The query returns the following results.


| column\_name | has\_column\_index | has\_offset\_index | 
| --- | --- | --- | 
| `order_id` | `false` | `false` | 
| `customer` | `false` | `false` | 
| `region` | `false` | `false` | 
| `amount` | `false` | `false` | 
| `order_date` | `false` | `false` | 

## `parquet_schema` function
<a name="athena-duckdb-functions-table-parquet-schema"></a>

Returns one row for each element of the schema in the footer of each Parquet file in `path`. The first element of each file is the root of the schema, and the other elements are the file's columns, including the fields of nested columns. Each row gives the element's name, its Parquet physical type (`type`), its logical and converted types, and whether it is required, optional, or repeated (`repetition_type`). It also gives the element's number of children, the scale and precision of a decimal, its field ID, and the type that DuckDB reads it as (`duckdb_type`).

Use `parquet_schema` to see the columns and types of a file without reading its data, or to see the field IDs that the data files of an Iceberg table store.

### Syntax
<a name="athena-duckdb-functions-table-parquet-schema-syntax"></a>

```sql
parquet_schema({{path}})
```

### Arguments
<a name="athena-duckdb-functions-table-parquet-schema-arguments"></a>

The `parquet_schema` function takes the following argument:

**{{path}}**  
The Amazon S3 location of the Parquet files: a `VARCHAR` path that can contain wildcards, such as `*`, or a list of such paths (`VARCHAR[]`).

### Return type
<a name="athena-duckdb-functions-table-parquet-schema-return-type"></a>

A table with one row per schema element. The `VARCHAR` columns are `file_name`, `name`, `type`, `type_length`, `repetition_type`, `converted_type`, `logical_type`, and `duckdb_type`. The `BIGINT` columns are `num_children`, `scale`, `precision`, `field_id`, and `column_id`.

### Examples
<a name="athena-duckdb-functions-table-parquet-schema-examples"></a>

The following SQL query returns each column of the Parquet file of `sales_parquet`, with its Parquet physical type and the type that the engine reads it as.

```sql
SELECT name, type, duckdb_type
FROM parquet_schema(
    's3://amzn-s3-demo-bucket/tables/sales_parquet/*'
)
WHERE type IS NOT NULL
ORDER BY column_id
```

The query returns the following results.


| name | type | duckdb\_type | 
| --- | --- | --- | 
| `order_id` | `INT32` | `INTEGER` | 
| `customer` | `BYTE_ARRAY` | `VARCHAR` | 
| `region` | `BYTE_ARRAY` | `VARCHAR` | 
| `amount` | `INT64` | `DECIMAL(10,2)` | 
| `order_date` | `INT32` | `DATE` | 

The following SQL query returns the Iceberg field ID of each column in a data file of the Iceberg table `orders_iceberg`.

```sql
SELECT name, field_id
FROM parquet_schema(
    's3://amzn-s3-demo-bucket/tables/orders_iceberg/data/01a20c06-c637-7eb5-bfd6-5b178259ba76.parquet'
)
WHERE field_id IS NOT NULL
ORDER BY field_id
```

The query returns the following results.


| name | field\_id | 
| --- | --- | 
| `order_id` | `1` | 
| `customer` | `2` | 
| `region` | `3` | 
| `amount` | `4` | 
| `order_date` | `5` | 

### Considerations
<a name="athena-duckdb-functions-table-parquet-schema-considerations"></a>

The root element has no type, so `type` and `duckdb_type` are `NULL` for it, and its name depends on the program that wrote the file. To list only the columns of a flat schema, filter on `type IS NOT NULL`.

In the result of `parquet_schema`, `column_id` is `0` for the root element, and the columns are numbered from `1`. In the result of `parquet_metadata`, the columns are numbered from `0`.