spicysharkco opened a new pull request, #11628:
URL: https://github.com/apache/arrow-rs/pull/11628

   # Which issue does this PR close?
   
   - Closes #11623
   
   # Rationale for this change
   
   A CSV column read as `Dictionary(<key>, Utf8)` panics with "dictionary key 
overflow" when a batch holds more distinct values than the key type can index 
(for example 129 for `Int8`). A value that does not parse as its column type 
already comes back as an `Err` from the reader, and so should this.
   
   # What changes are included in this PR?
   
   The eight per-key-type arms in `parse()` collected into 
`DictionaryArray<K>`, which goes through the infallible `append_value` of the 
dictionary builder. They now call one helper, `build_dictionary_array::<K>()`, 
which uses `StringDictionaryBuilder` and its fallible `append`, so the overflow 
comes back as `ArrowError::DictionaryKeyOverflowError`. Null handling is 
unchanged.
   
   # Are these changes tested?
   
   Yes. `test_csv_dictionary_key_overflow` reads a column with `Int8` keys: 128 
distinct values read fine, and 129 return `DictionaryKeyOverflowError`. Without 
the change the test panics in `GenericByteDictionaryBuilder`. The helper is 
shared by all eight key types, which `test_csv_with_nullable_dictionary` 
already reads.
   
   # Are there any significant user-facing changes?
   
   No.
   


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

Reply via email to