You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support creating arrays with non-nullable elements in make_array #11923
What might be the downside if the array is always nullable? Loss the possibility for non-null optimization?
If there is such a need for most of the functions, we might not need return_type anymore but return_type_from_exprs instead. That is a huge change.
What might be the downside if the array is always nullable? Loss the possibility for non-null optimization
That would be the main thing. In this case I came across this trying to integrate array support into datafusion-comet and it was inconsistent with Spark's handling of arrays. Maybe not the best reason to change, but it also seems weird to have nullability be tracked but not track it correctly.
If there is such a need for most of the functions, we might not need return_type anymore but return_type_from_exprs instead. That is a huge change.
The actual change per function isn't that much, working on what the make_array update would look like.
Alternatively, we switch all the function from return_type to return_type_from_exprs, since I think most of them would expect the same nullable from input.
After digging a little more it seems like there's some other issues that might make this significantly more difficult:
When invoke is called, there's no way to know the logical nullability of the ColumnarValue's/ArrayRef's being passed in. The only thing available is Array::is_nullable, but it looks like all that does it check if the current array has any nulls or not, so that could vary from batch to batch. So inside invoke there's no way to know if field inside
I remember there was a discussion about replacing ColumnarValue::Array(ArrayRef) with Recordbatch, which contains Schema
#[derive(Clone,Debug,PartialEq)]pubstructRecordBatch{schema:SchemaRef,columns:Vec<Arc<dynArray>>,/// The number of rows in this RecordBatch////// This is stored separately from the columns to handle the case of no columnsrow_count:usize,}
Activity
jayzhan211 commentedon Aug 10, 2024
What might be the downside if the array is always nullable? Loss the possibility for non-null optimization?
If there is such a need for most of the functions, we might not need
return_typeanymore butreturn_type_from_exprsinstead. That is a huge change.Kimahriman commentedon Aug 10, 2024
That would be the main thing. In this case I came across this trying to integrate array support into
datafusion-cometand it was inconsistent with Spark's handling of arrays. Maybe not the best reason to change, but it also seems weird to have nullability be tracked but not track it correctly.The actual change per function isn't that much, working on what the
make_arrayupdate would look like.Kimahriman commentedon Aug 10, 2024
One of the downstream affects would be ever so slightly increased encoding/decoding of Parquet files with arrays of non-nullable elements
jayzhan211 commentedon Aug 12, 2024
@alamb, I think we could have a breaking change on
return_typewithReturnTypeArgs, and removereturn_type_from_exprs.Alternatively, we switch all the function from
return_typetoreturn_type_from_exprs, since I think most of them would expect the samenullablefrom input.Kimahriman commentedon Aug 12, 2024
After digging a little more it seems like there's some other issues that might make this significantly more difficult:
invokeis called, there's no way to know the logical nullability of the ColumnarValue's/ArrayRef's being passed in. The only thing available isArray::is_nullable, but it looks like all that does it check if the current array has any nulls or not, so that could vary from batch to batch. So insideinvokethere's no way to know if field insideshould be logically nullable or not. And arrow will verify this when creating a record batch, which is the error I ran into initially with the nullability not matching: https://github.com/apache/arrow-rs/blob/5c5a94a11f01a286dd03b18af0f11c327a9accc6/arrow-array/src/record_batch.rs#L205
jayzhan211 commentedon Aug 12, 2024
We could have another
invoke_with_schemafunction to get thenullablefrom schema. Of course, another incompatible change 😢We have schema here
datafusion/datafusion/physical-expr/src/scalar_function.rs
Lines 214 to 239 in 18193e6
jayzhan211 commentedon Aug 12, 2024
I remember there was a discussion about replacing ColumnarValue::Array(ArrayRef) with Recordbatch, which contains
SchemaMaybe Recordbatch is what we need for
invoke🤔