Skip to content

fix(arrow): read CSV boolean columns like Java's CsvParser - #980

Open
jackylee-ch wants to merge 1 commit into
apache:mainfrom
jackylee-ch:fix/csv-boolean-parse-like-java
Open

jackylee-ch wants to merge 1 commit into
apache:mainfrom
jackylee-ch:fix/csv-boolean-parse-like-java

Conversation

@jackylee-ch

Copy link
Copy Markdown
Contributor

CSV boolean columns were cast with arrow_cast, whose string->boolean mapping reads 1, yes, t, on and y as true and unrecognized tokens such as 2 or invalid as null. Java CsvParser reads BOOLEAN via Boolean.parseBoolean: only true (case-insensitive) is true, every other non-null token is false, and it never yields null.

Reading the same CSV format-table file through Rust therefore flipped boolean values — 1/yes/t became true instead of false — and turned tokens like invalid into null, so WHERE flag = true returned different rows than Java, Spark or Flink over the same file.

Parse CSV boolean fields with the same rule so a format table reads identically across engines; null fields stay null. Verified by a unit test that fails under the old arrow_cast behavior.

CSV boolean columns were cast with `arrow_cast`, whose string->boolean
mapping reads "1", "yes", "t", "on" and "y" as true and unrecognized tokens
such as "2" or "invalid" as null. Java `CsvParser` reads BOOLEAN via
`Boolean.parseBoolean`: only "true" (case-insensitive) is true, every other
non-null token is false, and it never yields null. Reading the same CSV
format-table file through Rust therefore flipped boolean values (and produced
nulls) relative to Java, changing filter and query results across engines.

Parse CSV boolean fields with the same rule so a format table reads
identically across engines. Null fields stay null.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant