neilconway commented on code in PR #25389:
URL: https://github.com/apache/datafusion/pull/25389#discussion_r4037515876
##########
datafusion/physical-plan/src/unnest.rs:
##########
@@ -767,7 +767,22 @@ fn flatten_struct_cols(
DataType::Struct(_) => {
let struct_arr =
column_data.as_any().downcast_ref::<StructArray>().unwrap();
- Ok(struct_arr.columns().to_vec())
+ if struct_arr.null_count() == 0 {
+ Ok(struct_arr.columns().to_vec())
+ } else {
+ let validity = is_not_null(struct_arr)?;
+ struct_arr
+ .columns()
+ .iter()
+ .map(|column| {
+ Ok(zip(
+ &validity,
+ column,
+
&Scalar::new(new_null_array(column.data_type(), 1)),
+ )?)
+ })
+ .collect()
+ }
Review Comment:
`apply_parent_nulls` was added in #25122 ; can we use it here? It should
avoiding rebuilding the underlying value buffers, which will be a lot faster.
To be able to use it here, we might need to move `apply_parent_nulls` to a
location like `datafusion-common`, but that should be okay.
--
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]