You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "nathanb9 (via GitHub)" <gi...@apache.org> on 2026/06/12 21:52:19 UTC
[PR] Add ColumnarValue::to_array_variant method (follow-up to #22784) [datafusion]
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Add ColumnarValue::to_array_variant method (follow-up to #22784) [datafusion]
Posted by "nathanb9 (via GitHub)" <gi...@apache.org>.
nathanb9 closed pull request #22934: Add ColumnarValue::to_array_variant method (follow-up to #22784)
URL: https://github.com/apache/datafusion/pull/22934
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Add ColumnarValue::to_array_variant method (follow-up to #22784) [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #22934:
URL: https://github.com/apache/datafusion/pull/22934#issuecomment-4721530629
> Also, I guess why not just use ColumnarValue::into_array(num_rows)
Perhaps you can make a PR to adjust `expand_if_scalar` to do so
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Add ColumnarValue::to_array_variant method (follow-up to #22784) [datafusion]
Posted by "nathanb9 (via GitHub)" <gi...@apache.org>.
nathanb9 commented on PR #22934:
URL: https://github.com/apache/datafusion/pull/22934#issuecomment-4715551482
> it would be better for the use case to manually unwrap to just an array if it can only operate on arrays instead of doing this conversion
Makes sense.
Also, I guess why not just use `ColumnarValue::into_array(num_rows)`
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org