jorgecarleitao commented on a change in pull request #8170:
URL: https://github.com/apache/arrow/pull/8170#discussion_r487071953
##########
File path: rust/arrow/src/compute/kernels/take.rs
##########
@@ -425,22 +514,32 @@ mod tests {
#[test]
fn test_take_string() {
let index = UInt32Array::from(vec![Some(3), None, Some(1), Some(3),
Some(4)]);
- let mut builder: StringBuilder = StringBuilder::new(6);
- builder.append_value("one").unwrap();
- builder.append_null().unwrap();
- builder.append_value("three").unwrap();
- builder.append_value("four").unwrap();
- builder.append_value("five").unwrap();
- let array = Arc::new(builder.finish()) as ArrayRef;
- let a = take(&array, &index, None).unwrap();
- assert_eq!(a.len(), index.len());
- builder.append_value("four").unwrap();
- builder.append_null().unwrap();
- builder.append_null().unwrap();
- builder.append_value("four").unwrap();
- builder.append_value("five").unwrap();
- let b = builder.finish();
- assert_eq!(a.data(), b.data());
+
+ let array = StringArray::from(vec![
+ Some("one"),
+ None,
+ Some("three"),
+ Some("four"),
+ Some("five"),
+ ]);
+ let array = Arc::new(array) as ArrayRef;
+
+ let actual = take(&array, &index, None).unwrap();
+ assert_eq!(actual.len(), index.len());
+
+ let actual = actual.as_any().downcast_ref::<StringArray>().unwrap();
+
+ let expected =
+ StringArray::from(vec![Some("four"), None, None, Some("four"),
Some("five")]);
+
+ for i in 0..index.len() {
Review comment:
This test is semantically different(!). The new implementation takes all
values, irrespetively of the nullabillity, which causes `data()` to be
different. However, do take a critical view on this issue, please!
##########
File path: rust/arrow/src/compute/kernels/take.rs
##########
@@ -425,22 +514,32 @@ mod tests {
#[test]
fn test_take_string() {
let index = UInt32Array::from(vec![Some(3), None, Some(1), Some(3),
Some(4)]);
- let mut builder: StringBuilder = StringBuilder::new(6);
- builder.append_value("one").unwrap();
- builder.append_null().unwrap();
- builder.append_value("three").unwrap();
- builder.append_value("four").unwrap();
- builder.append_value("five").unwrap();
- let array = Arc::new(builder.finish()) as ArrayRef;
- let a = take(&array, &index, None).unwrap();
- assert_eq!(a.len(), index.len());
- builder.append_value("four").unwrap();
- builder.append_null().unwrap();
- builder.append_null().unwrap();
- builder.append_value("four").unwrap();
- builder.append_value("five").unwrap();
- let b = builder.finish();
- assert_eq!(a.data(), b.data());
+
+ let array = StringArray::from(vec![
+ Some("one"),
+ None,
+ Some("three"),
+ Some("four"),
+ Some("five"),
+ ]);
+ let array = Arc::new(array) as ArrayRef;
+
+ let actual = take(&array, &index, None).unwrap();
+ assert_eq!(actual.len(), index.len());
+
+ let actual = actual.as_any().downcast_ref::<StringArray>().unwrap();
+
+ let expected =
+ StringArray::from(vec![Some("four"), None, None, Some("four"),
Some("five")]);
+
+ for i in 0..index.len() {
Review comment:
This test is semantically different(!). The new implementation takes all
values, irrespetively of the nullabillity, which causes `data()` to be
different. Please take a critical view on this, as I am uncertain about the
details here.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]