Copilot commented on code in PR #49858:
URL: https://github.com/apache/arrow/pull/49858#discussion_r3277976240
##########
python/pyarrow/_dataset.pyx:
##########
@@ -2253,7 +2253,14 @@ cdef class CsvFileFormat(FileFormat):
"""
cdef CsvFileWriteOptions opts = \
<CsvFileWriteOptions> FileFormat.make_write_options(self)
- opts.write_options = WriteOptions(**kwargs)
+ # Start from the C++ defaults, which carry over fields from the
+ # format's parse_options (e.g. the delimiter), and apply caller
+ # overrides on top instead of replacing the WriteOptions object
+ # and discarding those defaults.
+ write_options = opts.write_options
+ for key, value in kwargs.items():
+ setattr(write_options, key, value)
Review Comment:
`CsvFileFormat.make_write_options(**kwargs)` previously constructed
`pyarrow.csv.WriteOptions(**kwargs)`, which ignores option values explicitly
passed as `None` (e.g. `delimiter=None` keeps the default) and raises a
`TypeError` for unknown keywords. The new `setattr` loop will now (1) try to
set `None` values and raise from the property setters, and (2) raise
`AttributeError` for unknown keys, which is a user-visible behavior change.
Consider skipping kwargs where `value is None`, and (optionally) catching
`AttributeError` to re-raise a `TypeError` matching the old constructor
behavior.
--
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]