You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "izveigor (via GitHub)" <gi...@apache.org> on 2023/07/25 21:04:29 UTC
[GitHub] [arrow-datafusion] izveigor commented on a diff in pull request #7057: feat: support SQL array replacement and removement functions
izveigor commented on code in PR #7057:
URL: https://github.com/apache/arrow-datafusion/pull/7057#discussion_r1274118911
##########
datafusion/physical-expr/src/array_expressions.rs:
##########
@@ -1957,20 +2175,124 @@ mod tests {
#[test]
fn test_array_remove() {
- // array_remove([1, 2, 3, 4], 3) = [1, 2, 4]
- let list_array = return_array();
- let arr = array_remove(&[
+ // array_remove([3, 1, 2, 3, 2, 3], 3) = [1, 2, 3, 2, 3]
+ let list_array = return_array_with_repeating_elements().into_array(1);
+ let array = array_remove(&[list_array, Arc::new(Int64Array::from_value(3, 1))])
+ .expect("failed to initialize function array_remove");
+ let result =
+ as_list_array(&array).expect("failed to initialize function array_remove");
+
+ assert_eq!(result.len(), 1);
+ assert_eq!(
+ &[1, 2, 3, 2, 3],
+ result
+ .value(0)
+ .as_any()
+ .downcast_ref::<Int64Array>()
+ .unwrap()
+ .values()
+ );
+
+ // array_remove([3, 1, 2, 3, 2, 3], 3, 2) = [1, 2, 2, 3]
+ let list_array = return_array_with_repeating_elements().into_array(1);
+ let array = array_remove(&[
list_array,
- ColumnarValue::Scalar(ScalarValue::Int64(Some(3))),
+ Arc::new(Int64Array::from_value(3, 1)),
+ Arc::new(Int64Array::from_value(2, 1)),
+ ])
+ .expect("failed to initialize function array_remove");
+ let result =
+ as_list_array(&array).expect("failed to initialize function array_remove");
+
+ assert_eq!(result.len(), 1);
+ assert_eq!(
+ &[1, 2, 2, 3],
+ result
+ .value(0)
+ .as_any()
+ .downcast_ref::<Int64Array>()
+ .unwrap()
+ .values()
+ );
+ }
+
+ #[test]
+ fn test_nested_array_remove() {
+ // array_remove(
+ // [[1, 2, 3, 4], [5, 6, 7, 8], [1, 2, 3, 4], [9, 10, 11, 12], [5, 6, 7, 8]],
+ // [1, 2, 3, 4],
+ // ) = [[5, 6, 7, 8], [1, 2, 3, 4], [9, 10, 11, 12], [5, 6, 7, 8]]
+ let list_array = return_nested_array_with_repeating_elements().into_array(1);
+ let element_array = return_array().into_array(1);
+ let array = array_remove(&[list_array, element_array])
+ .expect("failed to initialize function array_remove");
+ let result =
+ as_list_array(&array).expect("failed to initialize function array_remove");
+
+ assert_eq!(result.len(), 1);
+ let data = vec![
Review Comment:
I will deal with this issue later (in a separate PR)
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org