Jefffrey commented on code in PR #12268:
URL: https://github.com/apache/arrow-rs/pull/12268#discussion_r4626963331


##########
arrow-ipc/src/reader.rs:
##########
@@ -3166,6 +3168,101 @@ mod tests {
         assert_eq!(run_array_1_unsliced, output_batch.column(0).into_data());
     }
 
+    // Regression test for https://github.com/apache/arrow-rs/issues/12249:
+    // a zero-row slice of a RunEndEncoded array with Utf8View values did not
+    // read back, because the variadic buffer counts were computed from the
+    // original array while the writer wrote the buffers of the unsliced

Review Comment:
   this level of detail is far too verbose; cut it down. for example we dont 
need to state what the previous incorrect behaviour was



##########
arrow-ipc/src/reader.rs:
##########
@@ -3166,6 +3168,101 @@ mod tests {
         assert_eq!(run_array_1_unsliced, output_batch.column(0).into_data());
     }
 
+    // Regression test for https://github.com/apache/arrow-rs/issues/12249:
+    // a zero-row slice of a RunEndEncoded array with Utf8View values did not
+    // read back, because the variadic buffer counts were computed from the
+    // original array while the writer wrote the buffers of the unsliced
+    // (empty) run array.
+    #[test]
+    fn test_roundtrip_stream_run_array_zero_rows_utf8_view() {
+        let values = StringViewArray::from(vec!["a long string that is not 
inlined", "b"]);
+        let ree = RunArray::<Int32Type>::try_new(&Int32Array::from(vec![1, 
2]), &values).unwrap();
+        let batch = RecordBatch::try_from_iter([("a", Arc::new(ree) as 
ArrayRef)])
+            .unwrap()
+            .slice(1, 0);
+
+        let output = roundtrip_ipc_stream(&batch);
+        assert_eq!(output.num_rows(), 0);
+
+        let expected = unslice_run_array(batch.column(0).into_data()).unwrap();
+        assert_eq!(expected, output.column(0).into_data());
+    }
+
+    // Same as above, with the Utf8View values nested inside a ListView
+    // (see https://github.com/apache/arrow-rs/issues/12249).

Review Comment:
   we dont need to keep repeating the linked issue if we keep saying its same 
as above



##########
arrow-ipc/src/reader.rs:
##########
@@ -3166,6 +3168,101 @@ mod tests {
         assert_eq!(run_array_1_unsliced, output_batch.column(0).into_data());
     }
 
+    // Regression test for https://github.com/apache/arrow-rs/issues/12249:
+    // a zero-row slice of a RunEndEncoded array with Utf8View values did not
+    // read back, because the variadic buffer counts were computed from the
+    // original array while the writer wrote the buffers of the unsliced
+    // (empty) run array.
+    #[test]
+    fn test_roundtrip_stream_run_array_zero_rows_utf8_view() {
+        let values = StringViewArray::from(vec!["a long string that is not 
inlined", "b"]);
+        let ree = RunArray::<Int32Type>::try_new(&Int32Array::from(vec![1, 
2]), &values).unwrap();
+        let batch = RecordBatch::try_from_iter([("a", Arc::new(ree) as 
ArrayRef)])
+            .unwrap()
+            .slice(1, 0);
+
+        let output = roundtrip_ipc_stream(&batch);
+        assert_eq!(output.num_rows(), 0);
+
+        let expected = unslice_run_array(batch.column(0).into_data()).unwrap();
+        assert_eq!(expected, output.column(0).into_data());
+    }
+
+    // Same as above, with the Utf8View values nested inside a ListView
+    // (see https://github.com/apache/arrow-rs/issues/12249).
+    #[test]
+    fn test_roundtrip_stream_run_array_zero_rows_list_view_utf8_view() {
+        let mut list_builder = ListViewBuilder::new(StringViewBuilder::new());
+        list_builder
+            .values()
+            .append_value("a long string that is not inlined");
+        list_builder.values().append_value("b");
+        list_builder.append(true);
+        list_builder.values().append_value("c");
+        list_builder.append(true);
+        let values = list_builder.finish();
+
+        let ree = RunArray::<Int32Type>::try_new(&Int32Array::from(vec![1, 
2]), &values).unwrap();
+        let batch = RecordBatch::try_from_iter([("a", Arc::new(ree) as 
ArrayRef)])
+            .unwrap()
+            .slice(1, 0);
+
+        let output = roundtrip_ipc_stream(&batch);
+        assert_eq!(output.num_rows(), 0);
+
+        let expected = unslice_run_array(batch.column(0).into_data()).unwrap();
+        assert_eq!(expected, output.column(0).into_data());
+    }
+
+    // Same as above, with the Utf8View values nested inside a List
+    // (see https://github.com/apache/arrow-rs/issues/12249).
+    #[test]
+    fn test_roundtrip_stream_run_array_zero_rows_list_utf8_view() {
+        let mut list_builder = ListBuilder::new(StringViewBuilder::new());
+        list_builder
+            .values()
+            .append_value("a long string that is not inlined");
+        list_builder.values().append_value("b");
+        list_builder.append(true);
+        list_builder.values().append_value("c");
+        list_builder.append(true);
+        let values = list_builder.finish();
+
+        let ree = RunArray::<Int32Type>::try_new(&Int32Array::from(vec![1, 
2]), &values).unwrap();
+        let batch = RecordBatch::try_from_iter([("a", Arc::new(ree) as 
ArrayRef)])
+            .unwrap()
+            .slice(1, 0);
+
+        let output = roundtrip_ipc_stream(&batch);
+        assert_eq!(output.num_rows(), 0);
+
+        let expected = unslice_run_array(batch.column(0).into_data()).unwrap();
+        assert_eq!(expected, output.column(0).into_data());
+    }
+
+    // Regression test for https://github.com/apache/arrow-rs/issues/12249:

Review Comment:
   this comment needs to more clearly indicate how it differs from the above 
test cases; right now we have test case A which explains the scenario, then 
cases B & C following which indicate its the same as A with some modification, 
now we have this scenario D which again restates the scenario



-- 
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]

Reply via email to