GH-47499: [Python] explicitly add use_content_defined_chunking as parameter to ParquetWriter and ParquetWriter.write_table and show it as a parameter in doc page - #47498
Conversation
|
Thanks for opening a pull request! If this is not a minor PR. Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose Opening GitHub issues ahead of time contributes to the Openness of the Apache Arrow project. Then could you also rename the pull request title in the following format? or See also: |
|
cc @kszucs |
use_content_defined_chunking as a parameter in doc page
|
|
|
Also fixes #47477 |
|
Thank you for your contribution. Unfortunately, this pull request has been marked as stale because it has had no activity in the past 365 days. Please remove the stale label or comment below, or this PR will be closed in 14 days. Feel free to re-open this if it has been closed in error. If you do not have repository permissions to reopen the PR, please tag a maintainer. |
|
@severo thank you for your past contribution here! Would you be available to continue with this pull request, to rebase onto the latest main? And perhaps add an extra test like; diff --git a/python/pyarrow/tests/test_dataset.py b/python/pyarrow/tests/test_dataset.py
--- a/python/pyarrow/tests/test_dataset.py
+++ b/python/pyarrow/tests/test_dataset.py
@@ -5930,6 +5930,19 @@ def test_checksum_write_dataset_read_dataset_to_table(tempdir):
).to_table()
+@pytest.mark.parquet
+@pytest.mark.parametrize("cdc", [
+ True,
+ {"min_chunk_size": 32 * 1024, "max_chunk_size": 64 * 1024},
+])
+def test_write_dataset_content_defined_chunking(tempdir, cdc):
+ expected_table = pa.table({'a': [1, 2, 3]})
+ fmt = ds.ParquetFileFormat()
+ opts = fmt.make_write_options(use_content_defined_chunking=cdc)
+ ds.write_dataset(expected_table, tempdir, format=fmt, file_options=opts)
+ assert ds.dataset(tempdir, format=fmt).to_table().equals(expected_table)
+
+ |
|
Regarding #47477's side request
|
|
@tadeja essentially there are no meaningful effects on non-CAS storage systems, the data pages won't be fixed sized but mostly that's it. |
1e5a538 to
0cdabd3
Compare
|
Done. Thanks for the test. |
There was a problem hiding this comment.
🟢 Approval recommended
The change is a straightforward signature/plumbing update with a targeted regression test and consistent wiring to existing underlying option handling.
Pull request overview
Expose use_content_defined_chunking in the public Python API signatures (notably pyarrow.parquet.write_table) so it appears in the generated documentation parameter list, while keeping the existing behavior and wiring through to the underlying Parquet writer properties.
Changes:
- Added
use_content_defined_chunking(defaultFalse) toParquetWriter.__init__andwrite_tablesignatures and forwarded it into the underlying writer. - Plumbed
use_content_defined_chunkinginto dataset Parquet write options (ParquetFileWriteOptions) soParquetFileFormat.make_write_options(use_content_defined_chunking=...)works. - Added a dataset-level regression test covering
use_content_defined_chunkingfor both boolean and dict configurations.
File summaries
| File | Description |
|---|---|
| python/pyarrow/parquet/core.py | Adds the missing keyword to public signatures and forwards it to the underlying Parquet writer so docs show it. |
| python/pyarrow/_dataset_parquet.pyx | Adds the option to dataset Parquet write options defaults and passes it into writer property creation. |
| python/pyarrow/tests/test_dataset.py | Adds coverage for dataset writes using content-defined chunking (bool and dict forms). |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
🟡 Changes recommended
The write_table signature change reorders/inserts positional-or-keyword parameters, which is a backward-incompatible API change for positional callers.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
| data_page_size=None, | ||
| max_rows_per_page=None, | ||
| flavor=None, |
There was a problem hiding this comment.
🟢 Approval recommended
The changes consistently expose and plumb the option through writer and dataset paths, and include a targeted regression test for the new dataset behavior.
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0 new
- Review effort level: Lite
|
Thanks @severo, also for fixing numpydoc validation PR03 order error that finally showed up here in the CI Numpydoc job https://github.com/apache/arrow/actions/runs/34203717165/job/101988921363#step:6:4415 pyarrow.parquet.core.write_table
PR03: Wrong parameters order.
Actual: ('table', ..., 'data_page_size', 'flavor', ..., 'write_time_adjusted_to_utc', 'max_rows_per_page', 'bloom_filter_options', 'use_content_defined_chunking', '**kwargs').
Documented: ('table', ..., 'data_page_size', 'max_rows_per_page', 'flavor', ..., 'use_content_defined_chunking', 'write_time_adjusted_to_utc', 'bloom_filter_options', '**kwargs')
|
tadeja
left a comment
There was a problem hiding this comment.
@severo Could you just update PR description with the newest changes?
Also users won't get this error anymore
TypeError: unexpected parquet write option: use_content_defined_chunking
as it happens now when running with released wheel since 21.0.0 :
python -c "import pyarrow.dataset as ds; ds.ParquetFileFormat().make_write_options(use_content_defined_chunking=True)"or when running :
import pyarrow as pa, pyarrow.parquet as pq
pq.write_to_dataset(pa.table({'a':[1, 2, 3]}), 'cdc_dataset', use_content_defined_chunking=True)
Done. Feel free to update it directly if you think something is missing or wrong. |
|
@github-actions crossbow submit preview-docs |
|
Revision: 7e35b0f Submitted crossbow builds: ursacomputing/crossbow @ actions-020ac4b3c4
|
This reverts commit f8c04ef.
7e35b0f to
0d5d7b7
Compare
|
@github-actions crossbow submit preview-docs |
|
Revision: 0d5d7b7 Submitted crossbow builds: ursacomputing/crossbow @ actions-d1c4d05d2b
|
There was a problem hiding this comment.
🟡 Changes recommended
The dataset test must use sufficiently large data and observable CDC-specific output to validate option propagation.
Get a fresh assessment by requesting another Copilot review.
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
| expected_table = pa.table({'a': [1, 2, 3]}) | ||
| fmt = ds.ParquetFileFormat() | ||
| opts = fmt.make_write_options(use_content_defined_chunking=cdc) | ||
| ds.write_dataset(expected_table, tempdir, format=fmt, file_options=opts) | ||
| assert ds.dataset(tempdir, format=fmt).to_table().equals(expected_table) |
|
I've just done a fresh rebase to get around the failing preview-docs (minIO error 410 gone, resolved by recent commit 7e3b55a). |
|
Generated docs preview pages : pyarrow.parquet.write_table and pyarrow.parquet.ParquetWriter |
There was a problem hiding this comment.
Thanks for working on this @severo ! I think this PR is ready to merge. One nit - could you update PR/issue text/title to reflect that this also technically changes the API signature? (use_content_defined_chunking parameter is explicitly added to ParquetWriter and ParquetWriter.write_table). Also see #47498 (review) regarding the latent dataset bug this fixes.
use_content_defined_chunking as a parameter in doc pageuse_content_defined_chunking as parameter to ParquetWriter and ParquetWriter.write_table and show it as a parameter in doc page
|
Done! |
Rationale for this change
The doc page https://arrow.apache.org/docs/python/generated/pyarrow.parquet.write_table.html does not show
use_content_defined_chunkingas an argument ofwrite_table:Note that it's documented below in the list of parameters:
What changes are included in this PR?
Change the API signature of
ParquetWriterandParquetWriter.write_table:use_content_defined_chunkingparameter is explicitly added, with a default value (False), as mentioned by the comment:arrow/python/pyarrow/parquet/core.py
Lines 1953 to 1954 in 512dcd7
Reorder the parameters in docstring
_parquet_writer_arg_docsto match the method signature.Add a test.
Also users won't get this error anymore
TypeError: unexpected parquet write option: use_content_defined_chunkingas it happens now when running with released wheel since 21.0.0 :python -c "import pyarrow.dataset as ds; ds.ParquetFileFormat().make_write_options(use_content_defined_chunking=True)"or when running :
Are these changes tested?
Yes
Are there any user-facing changes?
Yes:
use_content_defined_chunkingparameter is explicitly added to the API signature ofParquetWriterandParquetWriter.write_tableuse_content_defined_chunkingas an argument ofwrite_table.use_content_defined_chunkingin the list of parameters ofparquet.write_table(doc) #47499