jdymitarai opened a new pull request, #26151: URL: https://github.com/apache/datafusion/pull/26151
## Which issue does this PR close? Closes #26012. ## Rationale for this change When evaluating `CASE <expr> WHEN <literal> ...` with two or more literal branches of byte-like types, DataFusion optimizes branch evaluation using `LiteralLookupTable` backed by `BytesLikeIndexMap`. In `try_get_bytes_iterator`, the match arm for `DataType::FixedSizeBinary(_)` was accidentally calling `array.as_binary::<i64>().into_iter()`, which attempts to downcast to `GenericBinaryArray<i64>` (LargeBinaryArray). When presented with a `FixedSizeBinaryArray`, Arrow's downcast fails and panics: ``` thread 'main' panicked at arrow-array-60.0.0/src/cast.rs:938:29: binary array ``` Note that the dictionary arm in the same file (`get_bytes_iterator_for_dictionary`) already used `.downcast_dict::<FixedSizeBinaryArray>()`, confirming this was an oversight in the flat array branch. ## What changes are included in this PR? - Correct the downcast in `try_get_bytes_iterator` for `DataType::FixedSizeBinary(_)` to use `array.as_fixed_size_binary().into_iter()`. - Add unit tests in `datafusion/physical-expr/src/expressions/case.rs` covering both `FixedSizeBinary` and dictionary-encoded `Dictionary(UInt8, FixedSizeBinary)` CASE evaluation. - Add regression tests in `datafusion/sqllogictest/test_files/case.slt` reproducing the issue query and verifying matching/non-matching branches. ## Are these changes tested? Yes: - Added unit tests `case_with_expr_fixed_size_binary` and `case_with_expr_fixed_size_binary_dictionary` in `datafusion-physical-expr`. - Added end-to-end regression tests in `case.slt`. - Verified all new and existing tests pass cleanly with `cargo test` and sqllogictest. ## Are there any user-facing changes? No API changes. Fixes a panic when evaluating `CASE` expressions with `FixedSizeBinary` literal branches. -- 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]
