nathanb9 opened a new pull request, #22784:
URL: https://github.com/apache/datafusion/pull/22784

   ## Which issue does this PR close?
   
   Closes #22781
   
   ## Rationale for this change
   
   `map(['a','b'], [col, col * 10])` fails at execution time with "map requires 
key and value lists to have the same length" when keys are all literals and 
values contain column references.
   
   Root cause: literal keys evaluate to 
`ColumnarValue::Scalar(FixedSizeList[N])` (length N) while column values 
evaluate to `ColumnarValue::Array` (length batch_size). The length check 
compares N != batch_size and errors.
   
   ## What changes are included in this PR?
   
   In `make_map_batch`: when one argument is scalar and the other is array, 
expand the scalar to match `batch_size` via 
`ScalarValue::to_array_of_size(number_rows)` before the length comparison.
   
   ## Are these changes tested?
   
   Yes.
   - Unit test: scalar keys + array values in `map.rs`
   - SLT test: `SELECT map(['a','b'], [column1, column1 * 10]) FROM (VALUES 
(1), (2), (3))`
   
   ## Are there any user-facing changes?
   
   No. Previously-failing queries now execute correctly.


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

Reply via email to