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

   ## Which issue does this PR close?
   
   Follow-up to #22784, addressing [a review 
comment](https://github.com/apache/datafusion/pull/22784#discussion_r3390019411)
 from @alamb suggesting the `expand_if_scalar` helper would make a good method 
on `ColumnarValue`.
   
   ## Rationale for this change
   
   `map.rs` had a private `expand_if_scalar` helper that expands a `Scalar` to 
an array while leaving an `Array` as is, keeping the value wrapped as a 
`ColumnarValue`. This is generally useful for functions that thread a 
`ColumnarValue` but need to assume a non-scalar input, so it belongs on 
`ColumnarValue` rather than in one function file.
   
   ## What changes are included in this PR?
   
   - Add `ColumnarValue::to_array_variant(&self, num_rows)`, which returns a 
`ColumnarValue` guaranteed to be the `Array` variant. It reuses the existing 
`to_array`, so a `Scalar` is expanded to `num_rows` and an `Array` is returned 
unchanged (no length validation).
   - Remove the private `expand_if_scalar` from `map.rs` and call the new 
method instead.
   
   ## Are these changes tested?
   
   Yes. Added a unit test for `to_array_variant` covering scalar expansion, 
array pass-through, and that an existing array is not length validated. 
Existing `map` unit tests and sqllogictests continue to pass.
   
   ## Are there any user-facing changes?
   
   Adds one public method to `ColumnarValue`. No behavior changes.
   


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