Skip to content

Commit be47667

Browse files
committed
fix: support map_values
1 parent 9d9ec25 commit be47667

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

native/spark-expr/src/array_funcs/get_array_struct_fields.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -151,20 +151,30 @@ fn get_array_struct_fields<O: OffsetSizeTrait>(
151151
.expect("A struct is expected");
152152

153153
let field = Arc::clone(&values.fields()[ordinal]);
154-
155-
// Get struct column by ordinal and attach null buffer from original values
156-
// In some cases, nulls in parent struct is not reflected in struct column.
157-
let data = values
158-
.column(ordinal)
159-
.into_data()
160-
.into_builder()
161-
.nulls(values.nulls().cloned())
162-
.build()?;
154+
// Get struct column by ordinal
155+
let column = values.column(ordinal);
156+
157+
let data = if values.null_count() == column.null_count() {
158+
Arc::clone(column)
159+
} else {
160+
// In some cases the column obtained from struct by ordinal doesn't
161+
// represent all nulls which imposed by parent values
162+
// which maybe caused by a low level reader bug and needs more investigation.
163+
// For this specific case patch the null buffer for column taking them
164+
// from parent values
165+
make_array(
166+
column
167+
.into_data()
168+
.into_builder()
169+
.nulls(values.nulls().cloned())
170+
.build()?,
171+
)
172+
};
163173

164174
let array = GenericListArray::new(
165175
field,
166176
list_array.offsets().clone(),
167-
make_array(data),
177+
data,
168178
list_array.nulls().cloned(),
169179
);
170180

0 commit comments

Comments
 (0)