alamb commented on code in PR #7650:
URL: https://github.com/apache/arrow-rs/pull/7650#discussion_r2150372756
##########
arrow-select/src/coalesce.rs:
##########
@@ -428,43 +381,76 @@ mod tests {
#[test]
fn test_string_view_no_views() {
- Test::new()
+ let output_batches = Test::new()
// both input batches have no views, so no need to compact
.with_batch(stringview_batch([Some("foo"), Some("bar")]))
.with_batch(stringview_batch([Some("baz"), Some("qux")]))
.with_expected_output_sizes(vec![4])
.run();
+
+ expect_buffer_layout(
+ col_as_string_view("c0", output_batches.first().unwrap()),
+ vec![],
+ );
}
#[test]
fn test_string_view_batch_small_no_compact() {
// view with only short strings (no buffers) --> no need to compact
let batch = stringview_batch_repeated(1000, [Some("a"), Some("b"),
Some("c")]);
- let gc_batches = Test::new()
+ let output_batches = Test::new()
.with_batch(batch.clone())
.with_expected_output_sizes(vec![1000])
.run();
let array = col_as_string_view("c0", &batch);
- let gc_array = col_as_string_view("c0", gc_batches.first().unwrap());
+ let gc_array = col_as_string_view("c0",
output_batches.first().unwrap());
assert_eq!(array.data_buffers().len(), 0);
assert_eq!(array.data_buffers().len(), gc_array.data_buffers().len());
// no compaction
+
+ expect_buffer_layout(gc_array, vec![]);
}
#[test]
fn test_string_view_batch_large_no_compact() {
// view with large strings (has buffers) but full --> no need to
compact
let batch = stringview_batch_repeated(1000, [Some("This string is
longer than 12 bytes")]);
- let gc_batches = Test::new()
+ let output_batches = Test::new()
.with_batch(batch.clone())
.with_batch_size(1000)
.with_expected_output_sizes(vec![1000])
.run();
let array = col_as_string_view("c0", &batch);
- let gc_array = col_as_string_view("c0", gc_batches.first().unwrap());
+ let gc_array = col_as_string_view("c0",
output_batches.first().unwrap());
assert_eq!(array.data_buffers().len(), 5);
assert_eq!(array.data_buffers().len(), gc_array.data_buffers().len());
// no compaction
+
+ expect_buffer_layout(
Review Comment:
I also added unit tests for the expected buffer layout as a lot of the
complexity is related to calculating this layour
--
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]