Skip to content

Add row_groups_per_file to to_parquet/write_parquet - #620

Open
joaquinhuigomez wants to merge 1 commit into
duckdb:mainfrom
joaquinhuigomez:fix/386-to-parquet-row-groups-per-file
Open

joaquinhuigomez wants to merge 1 commit into
duckdb:mainfrom
joaquinhuigomez:fix/386-to-parquet-row-groups-per-file

Conversation

@joaquinhuigomez

Copy link
Copy Markdown

The engine already supports the ROW_GROUPS_PER_FILE parquet COPY option, but the Python binding never exposed it, so rotating output files by row-group count was only reachable through raw SQL (#386).

This passes the argument through as a COPY option, mirroring the existing row_group_size handling: int-only validation in ToParquet, registered on both the to_parquet and write_parquet aliases, and added to the type stubs.

Tests follow the engine's own row_groups_per_file.test fixture (10k rows, row_group_size=2000, row_groups_per_file=1 → 5 files) on a threads=1 connection, since rotation is best-effort under multi-threaded writes; a second test covers the non-int rejection. Before the change both methods raise TypeError on the kwarg while the equivalent SQL COPY works. tests/fast/api passes (375 passed; the 2 new tests are the only delta vs. the pre-change baseline) and pre-commit (ruff, clang-format, mypy) is clean.

One note: row_groups_per_file=True is accepted because bool subclasses int — same pre-existing behavior as row_group_size, left untouched for consistency.

Fixes #386

The Parquet COPY option ROW_GROUPS_PER_FILE is supported by the engine
but was not exposed on DuckDBPyRelation.to_parquet/write_parquet, so
callers had to drop down to raw SQL to rotate output files by row group
count.

Pass the value straight through to the COPY options map. Validation
mirrors the neighbouring row_group_size block: non-integer input raises
InvalidInputException rather than reaching the engine.

Fixes duckdb#386
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant