Skip to content

Answer COPY TO with RETURN_STATS as the rows, sizes and column statistics of each Parquet file - #2999

Merged
tamnd merged 1 commit into
mainfrom
d5-return-stats
Oct 10, 2026
Merged

tamnd merged 1 commit into
mainfrom
d5-return-stats

Conversation

@tamnd

@tamnd tamnd commented Oct 10, 2026

Copy link
Copy Markdown
Owner

Part of #1446.

COPY ... TO a Parquet file now takes RETURN_STATS. The copy answers one row per file with filename, count, file_size_bytes, footer_size_bytes, column_statistics, partition_keys and extra_info, with the same types as the pin.

column_statistics maps each column, named in double quotes with inner quotes doubled, to its column_size_bytes, null_count, num_values and, when the column has values, its bounds with min_is_exact and max_is_exact. The keys are sorted, as the pin sorts them. A bool reports 1 and 0, a blob reports its bytes in hex, and a string or blob longer than 256 bytes is cut short and marked as not exact, with the upper bound raised so it stays above every value. partition_keys holds the partition values as text in the order of PARTITION_BY and is NULL for a copy that is not partitioned. extra_info holds the row group count.

A float column also reports has_nan and nan_count, counted over every row group. This follows the corpus, which comes from a DuckDB newer than the pin. v2.0.0-dev84237 has no nan_count and only keeps has_nan from the last row group it wrote. A column with no values reports neither, as in the pin.

The Parquet writer keeps running totals for each column as it writes row groups, and hands back the footer size when it finishes. The sizes are the writer's own, so they differ from the pin's byte for byte, which the corpus allows for with a regex.

@tamnd tamnd added kind/compat A gap against DuckDB, on any of the six surfaces. area/duckdb-compat The DuckDB compatibility surfaces. labels Oct 10, 2026
@tamnd
tamnd merged commit 5df6dd1 into main Oct 10, 2026
1 check failed
@tamnd
tamnd deleted the d5-return-stats branch October 10, 2026 04:00
@tamnd tamnd mentioned this pull request Oct 10, 2026
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/duckdb-compat The DuckDB compatibility surfaces. kind/compat A gap against DuckDB, on any of the six surfaces.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant