vegarsti commented on code in PR #17732:
URL: https://github.com/apache/datafusion/pull/17732#discussion_r2400020895
##########
datafusion/common/src/scalar/mod.rs:
##########
@@ -3305,17 +3306,29 @@ impl ScalarValue {
/// assert_eq!(scalar_vec, expected);
/// ```
pub fn convert_array_to_scalar_vec(array: &dyn Array) ->
Result<Vec<Vec<Self>>> {
- let mut scalars = Vec::with_capacity(array.len());
-
- for index in 0..array.len() {
- let nested_array = array.as_list::<i32>().value(index);
- let scalar_values = (0..nested_array.len())
- .map(|i| ScalarValue::try_from_array(&nested_array, i))
- .collect::<Result<Vec<_>>>()?;
- scalars.push(scalar_values);
+ fn generic_collect<OffsetSize: OffsetSizeTrait>(
+ array: &dyn Array,
+ ) -> Result<Vec<Vec<ScalarValue>>> {
+ array
+ .as_list::<OffsetSize>()
+ .iter()
+ .map(|nested_array| match nested_array {
+ Some(nested_array) => (0..nested_array.len())
+ .map(|i| ScalarValue::try_from_array(&nested_array, i))
+ .collect::<Result<Vec<_>>>(),
+ // TODO: what can we put for null?
+ None => Ok(vec![]),
+ })
+ .collect()
Review Comment:
I've made an attempt at fixing this here
https://github.com/apache/datafusion/pull/17891, but I'm not sure about the
null semantics. I should add a new test case for array_has, but haven't come up
with one yet.
--
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]