GH-53290: [Python] CSV: expose pad_short_rows parse option in Python #54691
All Vouch review confidence checks passed
Residual risk 0.26 = Change Risk (0.47) × (1 − Review Confidence (0.45)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.47 · 314 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.344
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #54691"
general
weight: 0.35
HuaHuaY
### Rationale for this change
In #50926,
pad_short_rowswas implemented in the C++ CSV parser/reader (arrow::csv::ParseOptions::pad_short_rows), allowing rows with fewer fields than expected to be padded with null values rather than failing. However, this option was not yet exposed to the Python bindings (#53290).What changes are included in this PR?
pad_short_rowsonCCSVParseOptionsinpython/pyarrow/includes/libarrow.pxd.pad_short_rowsparameter topyarrow.csv.ParseOptions.__init__, defaulting toNone(preserving C++ defaultfalse).pad_short_rowsproperty (getter and setter) onpyarrow.csv.ParseOptions.ParseOptions.equals(),_repr_base(),__getstate__(), and__setstate__().ParseOptions.pad_short_rowsindocs/source/python/csv.rst.python/pyarrow/tests/test_csv.py:- Options validation, string/repr output, and serialization/pickling.
- Equality differentiation when only
pad_short_rowsdiffers.- CSV table and streaming reading with
pad_short_rows=Trueacross serial and parallel readers for numerical and string datasets.- Distinction between missing trailing fields (padded as nulls) and explicitly empty fields (preserved as empty strings).
- Verification that excess columns still raise an error.
- Header-only CSV input verification.
- Verification that default
pad_short_rows=Falseretains strict error behavior.- Reading with explicit column names (including when the first row is short) and typed schema conversions.
python/pyarrow/tests/test_dataset.pyfords.CsvFileFormat(pa.csv.ParseOptions(pad_short_rows=True))pickling and dataset reading viads.dataset().Are these changes tested?
Yes. Added tests in
test_csv.pyandtest_dataset.pycovering parse options validation, pickling, repr, and reading short rows across serial, parallel, streaming, and dataset readers.Are there any user-facing changes?
Yes.
pyarrow.csv.ParseOptionsnow acceptspad_short_rows(defaulting toFalse), allowing users to opt into padding short rows with nulls.Was AI used for this PR?
AI assistance was used for code drafting, technical audit, and test authoring. The architecture, C++ mapping, test cases, and documentation were reviewed and verified.
PR code and description written by:
Reviewed before submission by: