vegarsti commented on code in PR #17891:
URL: https://github.com/apache/datafusion/pull/17891#discussion_r2403797842
##########
datafusion/common/src/scalar/mod.rs:
##########
@@ -9074,9 +9116,63 @@ mod tests {
assert_eq!(
converted,
vec![
- vec![ScalarValue::Int64(Some(1)), ScalarValue::Int64(Some(2))],
- vec![],
- vec![ScalarValue::Int64(Some(5))],
+ Some(vec![
+ ScalarValue::Int64(Some(1)),
+ ScalarValue::Int64(Some(2))
+ ]),
+ None,
+ Some(vec![ScalarValue::Int64(Some(5))]),
+ ]
+ );
+
+ // 4: Offsets + Values looks like this: [[1, 2], [], [5]]
+ // But with NullBuffer it's like this: [[1, 2], NULL, [5]]
+ // The converted result is: [[1, 2], None, [5]]
+ let array4 = ListArray::new(
+ Field::new_list_field(DataType::Int64, true).into(),
+ OffsetBuffer::new(vec![0, 2, 2, 5].into()),
+ Arc::new(Int64Array::from(vec![1, 2, 3, 4, 5, 6])),
+ Some(NullBuffer::from(vec![true, false, true])),
+ );
+ let converted =
ScalarValue::convert_array_to_scalar_vec(&array4).unwrap();
+ assert_eq!(
+ converted,
+ vec![
+ Some(vec![
+ ScalarValue::Int64(Some(1)),
+ ScalarValue::Int64(Some(2))
+ ]),
+ None,
+ Some(vec![
+ ScalarValue::Int64(Some(3)),
+ ScalarValue::Int64(Some(4)),
+ ScalarValue::Int64(Some(5)),
+ ]),
+ ]
+ );
Review Comment:
On main the middle element here would be an empty vec, not `None`.
##########
datafusion/common/src/scalar/mod.rs:
##########
@@ -9074,9 +9116,63 @@ mod tests {
assert_eq!(
converted,
vec![
- vec![ScalarValue::Int64(Some(1)), ScalarValue::Int64(Some(2))],
- vec![],
- vec![ScalarValue::Int64(Some(5))],
+ Some(vec![
+ ScalarValue::Int64(Some(1)),
+ ScalarValue::Int64(Some(2))
+ ]),
+ None,
+ Some(vec![ScalarValue::Int64(Some(5))]),
+ ]
+ );
+
+ // 4: Offsets + Values looks like this: [[1, 2], [], [5]]
+ // But with NullBuffer it's like this: [[1, 2], NULL, [5]]
+ // The converted result is: [[1, 2], None, [5]]
+ let array4 = ListArray::new(
+ Field::new_list_field(DataType::Int64, true).into(),
+ OffsetBuffer::new(vec![0, 2, 2, 5].into()),
+ Arc::new(Int64Array::from(vec![1, 2, 3, 4, 5, 6])),
+ Some(NullBuffer::from(vec![true, false, true])),
+ );
+ let converted =
ScalarValue::convert_array_to_scalar_vec(&array4).unwrap();
+ assert_eq!(
+ converted,
+ vec![
+ Some(vec![
+ ScalarValue::Int64(Some(1)),
+ ScalarValue::Int64(Some(2))
+ ]),
+ None,
+ Some(vec![
+ ScalarValue::Int64(Some(3)),
+ ScalarValue::Int64(Some(4)),
+ ScalarValue::Int64(Some(5)),
+ ]),
+ ]
+ );
+
+ // 5: Offsets + Values looks like this: [[1, 2], [], [5]]
+ // Same as 4, but the middle array is not null, so after conversion
it's empty.
+ let array5 = ListArray::new(
+ Field::new_list_field(DataType::Int64, true).into(),
+ OffsetBuffer::new(vec![0, 2, 2, 5].into()),
+ Arc::new(Int64Array::from(vec![1, 2, 3, 4, 5, 6])),
+ Some(NullBuffer::from(vec![true, true, true])),
+ );
+ let converted =
ScalarValue::convert_array_to_scalar_vec(&array5).unwrap();
+ assert_eq!(
+ converted,
+ vec![
+ Some(vec![
+ ScalarValue::Int64(Some(1)),
+ ScalarValue::Int64(Some(2))
+ ]),
+ Some(vec![]),
+ Some(vec![
+ ScalarValue::Int64(Some(3)),
+ ScalarValue::Int64(Some(4)),
+ ScalarValue::Int64(Some(5)),
+ ]),
]
Review Comment:
On main the middle element here would also be an empty vec, not `None`.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]