Ivan-gfan opened a new issue, #13423: URL: https://github.com/apache/seatunnel/issues/13423
### Search before asking - [x] I had searched in the [issues](https://github.com/apache/seatunnel/issues?q=is%3Aissue+label%3A%22bug%22) and found no similar issues. ### What happened With `file_format_type = csv`, `csv_use_header_line = true` and `enable_file_split = true`, the header is ignored and every row is read by position in `schema` order. When the column order in the file differs from the `schema`, values are put in the wrong columns: - If the types do not match, the job fails (config and exception below). - If they do, the job succeeds with wrong data. For example, a file with header `last,first` and row `Smith,John`, read with schema `first = string, last = string`, gives `first = Smith, last = John`. The same file and config without `enable_file_split` are read correctly, because there the header names are matched against the schema. Cause: - `FileSplitStrategyFactory` gives `AccordingToSplitSizeSplitStrategy` `skipHeaderRowNumber = 1` when `csv_use_header_line` is set, so the first split starts after the header line. No split starts at offset 0. - `CsvReadStrategy#getHeaders` (and `getCSVFormat`) only parse the header for a split with `start == 0`. For any other split they fall back to the schema column names, in schema order, as the header. So with splitting enabled, `csv_use_header_line` never takes effect. Data file `/data/csv/header/data.csv` used with the config below: ``` name,id,is_female tom,20,true ``` ### SeaTunnel Version 3.1.0 and current `dev` (3.1.1-SNAPSHOT). ### SeaTunnel Config ```conf env { parallelism = 1 job.mode = "BATCH" } source { LocalFile { path = "/data/csv/header" file_format_type = csv csv_use_header_line = true enable_file_split = true file_split_size = 8 schema = { fields { id = int name = string is_female = boolean } } } } sink { Console {} } ``` ### Running Command ```shell ./bin/seatunnel.sh --config csv_header_split.conf -m local ``` ### Error Exception ```log java.lang.NumberFormatException: For input string: "tom" ("tom" is the name column of the file, read into id, the first column of the schema.) ``` ### Zeta or Flink or Spark Version Zeta ### Java or Scala Version Java 11 ### Screenshots _No response_ ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- 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]
