Skip to content

Commit

Permalink
add largelist for slt
Browse files Browse the repository at this point in the history
  • Loading branch information
my-vegetable-has-exploded committed Nov 27, 2023
1 parent 86ccb87 commit ccfed93
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 27 deletions.
27 changes: 0 additions & 27 deletions datafusion/physical-expr/src/array_expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3094,31 +3094,4 @@ mod tests {

make_array(&[arr1, arr2]).expect("failed to initialize function array")
}

#[test]
fn test_array_distinct() {
// test: from array [[1, 3, 2, 3, 1, 2, 4], [1, 1]] to [[1, 2, 3, 4], [1]]
let data = vec![
Some(vec![
Some(1),
Some(3),
Some(2),
Some(3),
Some(1),
Some(2),
Some(4),
]),
Some(vec![Some(1), Some(1)]),
];
let excepted = vec![
Some(vec![Some(1), Some(2), Some(3), Some(4)]),
Some(vec![Some(1)]),
];
let input =
Arc::new(ListArray::from_iter_primitive::<Int64Type, _, _>(data)) as ArrayRef;
let excepted = ListArray::from_iter_primitive::<Int64Type, _, _>(excepted);
let result = array_distinct(&[input]).unwrap();
let result = as_list_array(&result).unwrap();
assert_eq!(result, &excepted);
}
}
16 changes: 16 additions & 0 deletions datafusion/sqllogictest/test_files/array.slt
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,14 @@ AS VALUES
(make_array([5,6], [5,6], NULL))
;

statement ok
CREATE TABLE array_distinct_table_1D_large
AS VALUES
(arrow_cast(make_array(1, 1, 2, 2, 3), 'LargeList(Int64)')),
(arrow_cast(make_array(1, 2, 3, 4, 5), 'LargeList(Int64)')),
(arrow_cast(make_array(3, 5, 3, 3, 3), 'LargeList(Int64)'))
;

statement ok
CREATE TABLE array_intersect_table_1D
AS VALUES
Expand Down Expand Up @@ -2691,6 +2699,14 @@ from array_distinct_table_2D;
[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]
[, [5, 6]]

query ?
select array_distinct(column1)
from array_distinct_table_1D_large;
----
[1, 2, 3]
[1, 2, 3, 4, 5]
[3, 5]

query ???
select array_intersect(column1, column2),
array_intersect(column3, column4),
Expand Down

0 comments on commit ccfed93

Please sign in to comment.