fix(arrow-data): don't panic on dictionary key overflow in interleave/concat - #10675
Open
okhsunrog wants to merge 1 commit into
Open
fix(arrow-data): don't panic on dictionary key overflow in interleave/concat#10675okhsunrog wants to merge 1 commit into
okhsunrog wants to merge 1 commit into
Conversation
MutableArrayData::new / with_capacities unconditionally concatenate dictionaries whose values aren't the same underlying buffer, and .expect() the result. When the combined dictionary genuinely exceeds the key type's range (e.g. merging independently dictionary-encoded partitions with UInt16 keys), this panics instead of surfacing a catchable error. The same construction is used recursively for dictionaries nested inside List/FixedSizeList/Struct/RunEndEncoded/ Union children, so the panic isn't limited to top-level dictionary arrays. Add fallible try_new / try_with_capacities that return Err(ArrowError::DictionaryKeyOverflowError) instead of panicking, and switch arrow-select's interleave_fallback and concat_fallback (the paths reached for dictionary arrays that can't/shouldn't be merged), including their recursive descent into nested children, to use them. new()/with_capacities() keep their existing panicking behavior for all other callers.
Author
|
Also probably related to #10553 |
Author
|
@Jefffrey could you review this one please? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
interleave()andconcat()document aResultreturn type, but forDictionary<K, Utf8View>/Dictionary<K, BinaryView>arrays (top-level or nested inside aList/FixedSizeList/Struct/RunEndEncoded/Union), a genuine dictionary key overflow currently panics instead of returningErr. This happens because the fallback path builds aMutableArrayDatadirectly and.expect()s the dictionary-concat result, andMutableArrayData::new/with_capacitieshave no fallible variant. See #10674 for the full analysis and a minimal repro.What changes are included in this PR?
MutableArrayData::try_new/try_with_capacities, fallible variants ofnew/with_capacitiesthat returnErr(ArrowError::DictionaryKeyOverflowError)instead of panicking on dictionary key overflow.new()/with_capacities()keep their existing panicking behavior (now implemented astry_with_capacities(..).expect(..)) for the many existing callers that rely on infallibility.try_with_capacities(forList/LargeList/Map/ListView/LargeListView/FixedSizeList/Struct/RunEndEncoded/Union) also uses the fallible variants and propagates errors with?, so dictionaries nested inside container types are covered, not just top-level dictionary arrays.arrow-select'sinterleave_fallbackandconcat_fallback(the paths reached for dictionary arrays whose values can't/shouldn't be merged) to the fallible constructors.Are these changes tested?
Yes:
concat_string_view_dictionary_overflow_returns_err/test_interleave_string_view_dictionary_overflow_returns_err: top-levelDictionary<UInt8, Utf8View>overflow returnsErrinstead of panicking.concat_nested_dictionary_overflow_returns_err/test_interleave_nested_dictionary_overflow_returns_err: same overflow nested inside aFixedSizeList, exercising the recursive child construction.Full
arrow-data/arrow-selecttest suites pass (410 tests),cargo fmt --checkandcargo clippy --all-targets -- -D warningsare clean for both crates.Are there any user-facing changes?
No breaking changes.
MutableArrayData::new/with_capacitieskeep their documented panicking behavior and signatures. Two new public fallible methods are added (try_new,try_with_capacities).interleave()/concat()keep their existingResultsignature -- the only visible change is that a specific previously-panicking input (genuine dictionary key overflow onUtf8View/BinaryViewdictionaries) now returnsErr(ArrowError::DictionaryKeyOverflowError)instead.