Jefffrey commented on code in PR #18531:
URL: https://github.com/apache/datafusion/pull/18531#discussion_r2532531576
##########
datafusion/functions-nested/src/map.rs:
##########
@@ -393,17 +466,133 @@ fn make_map_array_internal<O: OffsetSizeTrait>(
.add_child_data(flattened_values.to_data())
.build()?;
- let map_data = ArrayData::builder(DataType::Map(
+ let mut map_data_builder = ArrayData::builder(DataType::Map(
Arc::new(Field::new(
"entries",
struct_data.data_type().clone(),
false,
)),
false,
))
- .len(keys.len())
+ .len(original_len) // Use the original number of rows, not the filtered
count
.add_child_data(struct_data)
- .add_buffer(Buffer::from_slice_ref(offset_buffer.as_slice()))
- .build()?;
+ .add_buffer(Buffer::from_slice_ref(offset_buffer.as_slice()));
+
+ // Add the nulls bitmap if present (to preserve NULL map values)
+ if let Some(nulls) = nulls_bitmap {
+ map_data_builder = map_data_builder.nulls(Some(nulls));
+ }
+
+ let map_data = map_data_builder.build()?;
Ok(ColumnarValue::Array(Arc::new(MapArray::from(map_data))))
}
+
+#[cfg(test)]
+mod tests {
Review Comment:
> The behavior is similar, but I'm concerned that datafusion-cli may apply
certain optimizations that mask the issue.
I disagree with this as this behaviour seems like something that would be
preserved across optimizations; in that it seems pretty standard handling of
nulls in the input arrays that I can't see being optimized away by some rule 🤔
--
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]