pearu commented on code in PR #54691:
URL: https://github.com/apache/arrow/pull/54691#discussion_r4800508484
##########
python/pyarrow/tests/test_csv.py:
##########
@@ -766,6 +773,101 @@ def row_num(x):
'b': ["e", "j"],
}
+ def test_pad_short_rows(self):
Review Comment:
I think Python tests only need to show that the option reaches the C++
reader. Most cases in `test_pad_short_rows` are already covered in C++, so one
read with padding is enough:
```suggestion
def test_pad_short_rows(self):
rows = b"1,2\n3,4,5,6\n"
table = self.read_bytes(
rows,
read_options=ReadOptions(column_names=["w", "x", "y", "z"]),
parse_options=ParseOptions(pad_short_rows=True),
)
assert table.to_pydict() == {
"w": [1, 3],
"x": [2, 4],
"y": [None, 5],
"z": [None, 6],
}
```
##########
python/pyarrow/tests/test_dataset.py:
##########
@@ -3567,6 +3568,28 @@ def test_csv_format_options_generate_columns(tempdir,
dataset_reader):
'f3': pa.array([1])}))
+def test_csv_format_pad_short_rows(tempdir, dataset_reader):
+ path = str(tempdir / 'short.csv')
+ with open(path, 'w') as sink:
+ sink.write('a,b,c\n1,2,3\n4,5\n6\n')
+
+ # Default format fails on short rows
+ with pytest.raises(pa.ArrowInvalid, match="Expected 3 columns, got 2:
4,5"):
+ ds.dataset(path, format='csv')
Review Comment:
Strictly speaking, this is not about the new option, so I'd suggest:
```suggestion
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]