lidavidm commented on a change in pull request #10134:
URL: https://github.com/apache/arrow/pull/10134#discussion_r618624665
##########
File path: cpp/src/arrow/dataset/file_csv.cc
##########
@@ -90,9 +90,9 @@ static inline Result<csv::ConvertOptions> GetConvertOptions(
GetFragmentScanOptions<CsvFragmentScanOptions>(
kCsvTypeName, scan_options.get(),
format.default_fragment_scan_options));
auto convert_options = csv_scan_options->convert_options;
- for (FieldRef ref : scan_options->MaterializedFields()) {
- ARROW_ASSIGN_OR_RAISE(auto field,
ref.GetOne(*scan_options->dataset_schema));
-
+ // Properly set conversion types even for non-materialized fields
+ // (since we're reading all of them anyways)
+ for (auto field : scan_options->dataset_schema->fields()) {
Review comment:
Unifying the tests led me to discover this, which I think inadvertently
fixes a bug I ran into in ARROW-9697 that I hadn't figured out before. There, I
found that for CSV fragments `to_table(schema=..., columns=[])` would fail when
`to_table(schema=...)` did not fail, because in the former case, the CSV reader
would complain about an invalid cast, seemingly ignoring the schema set.
I think this isn't the best solution, however; we should actually be
deriving `include_columns`.
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]