xudong963 opened a new pull request, #27846:
URL: https://github.com/apache/datafusion/pull/27846

   ## Which issue does this PR close?
   
   - Backport of #27021 to `branch-56`, for #24463.
   - Closes #27020 for the 56 line.
   
   ## Rationale for this change
   
   arrow-csv maps CSV columns by position. When files in one table have 
different column layouts, values land in the wrong columns or parsing fails. 
#27021 adds an opt-in `match_columns_by_header` option that maps each file's 
columns to the table schema by header name. Users on 56 who read CSV files 
whose layout changed over time need this before 57.
   
   ## What changes are included in this PR?
   
   A cherry-pick of #27021 (`3f837ad`) with `-x`. The only conflict was in 
`docs/source/library-user-guide/upgrading/56.0.0.md`: on `main` that file also 
has a section from an unrelated PR (`CreateFunction` field types), so I kept 
only the `match_columns_by_header` section.
   
   ## What is the testing strategy for this PR?
   
   The tests from #27021 pass on this branch: the `datafusion-datasource-csv` 
unit tests, the CSV tests in `core_integration`, the proto round-trip tests, 
`csv_files.slt` and `information_schema.slt`.
   
   Applied on `branch-56` together with the backports of #27150, #27547, #27732 
and #26261 (opened alongside this one), the full sqllogictest suite, `cargo fmt 
--check` and clippy on the touched crates also pass.
   
   ## Are there any user-facing changes?
   
   - New opt-in `format.match_columns_by_header` option, default `false`. 
Existing reads are unchanged.
   - API: `CsvOptions` and `CsvReadOptions` gain a public 
`match_columns_by_header` field. Neither struct is `#[non_exhaustive]`, so code 
that builds them with an exhaustive struct literal stops compiling until it 
adds the field or uses `..Default::default()`. This is noted in the 56.0.0 
upgrade guide. Please weigh this for a minor release.
   - Proto: `CsvOptions` (field 23) and `CsvScanExecNode` (field 10) gain the 
same field, with the same field numbers as `main`.
   


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to