Skip to content

Commit 1fd926f

Browse files
committed
switch to unchecked when building array.
1 parent f76c376 commit 1fd926f

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

datafusion/physical-plan/src/aggregates/group_values/group_column.rs

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -680,14 +680,32 @@ impl<B: ByteViewType> ByteViewGroupValueBuilder<B> {
680680

681681
// Build array and return
682682
let views = ScalarBuffer::from(first_n_views);
683-
Arc::new(GenericByteViewArray::<B>::new(views, buffers, null_buffer))
683+
684+
// Safety:
685+
// * all views were correctly made
686+
// * (if utf8): Input was valid Utf8 so buffer contents are
687+
// valid utf8 as well
688+
unsafe {
689+
Arc::new(GenericByteViewArray::<B>::new_unchecked(
690+
views,
691+
buffers,
692+
null_buffer,
693+
))
694+
}
684695
} else {
685696
let views = ScalarBuffer::from(first_n_views);
686-
Arc::new(GenericByteViewArray::<B>::new(
687-
views,
688-
Vec::new(),
689-
null_buffer,
690-
))
697+
698+
// Safety:
699+
// * all views were correctly made
700+
// * (if utf8): Input was valid Utf8 so buffer contents are
701+
// valid utf8 as well
702+
unsafe {
703+
Arc::new(GenericByteViewArray::<B>::new_unchecked(
704+
views,
705+
Vec::new(),
706+
null_buffer,
707+
))
708+
}
691709
}
692710
}
693711

@@ -1090,7 +1108,7 @@ mod tests {
10901108
// 3. Take non-inlined + partial last buffer in `completed`
10911109
// 4. Take non-inlined + whole last buffer in `completed`
10921110
// 5. Take non-inlined + partial last `in_progress`
1093-
// 6. Take non-inlined + while last buffer in ``in_progress`
1111+
// 6. Take non-inlined + while last buffer in `in_progress`
10941112
// 7. Take all views at once
10951113

10961114
let mut builder =

0 commit comments

Comments
 (0)