This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new 4068b06148 Minor: remove duplicated `array_replace` tests (#8066)
4068b06148 is described below
commit 4068b0614877b5650b4e702e26d9f263802198fa
Author: Andrew Lamb <[email protected]>
AuthorDate: Sat Nov 11 06:14:13 2023 -0500
Minor: remove duplicated `array_replace` tests (#8066)
* Add whitespace
* remove redundant test
* remove unused code
---
datafusion/physical-expr/src/array_expressions.rs | 198 ----------------------
datafusion/sqllogictest/test_files/array.slt | 137 ++++++++++++---
2 files changed, 118 insertions(+), 217 deletions(-)
diff --git a/datafusion/physical-expr/src/array_expressions.rs
b/datafusion/physical-expr/src/array_expressions.rs
index 87ba77b497..54452e3653 100644
--- a/datafusion/physical-expr/src/array_expressions.rs
+++ b/datafusion/physical-expr/src/array_expressions.rs
@@ -2775,193 +2775,6 @@ mod tests {
);
}
- #[test]
- fn test_array_replace() {
- // array_replace([3, 1, 2, 3, 2, 3], 3, 4) = [4, 1, 2, 3, 2, 3]
- let list_array = return_array_with_repeating_elements();
- let array = array_replace(&[
- list_array,
- Arc::new(Int64Array::from_value(3, 1)),
- Arc::new(Int64Array::from_value(4, 1)),
- ])
- .expect("failed to initialize function array_replace");
- let result =
- as_list_array(&array).expect("failed to initialize function
array_replace");
-
- assert_eq!(result.len(), 1);
- assert_eq!(
- &[4, 1, 2, 3, 2, 3],
- result
- .value(0)
- .as_any()
- .downcast_ref::<Int64Array>()
- .unwrap()
- .values()
- );
- }
-
- #[test]
- fn test_nested_array_replace() {
- // array_replace(
- // [[1, 2, 3, 4], [5, 6, 7, 8], [1, 2, 3, 4], [9, 10, 11, 12], [5,
6, 7, 8]],
- // [1, 2, 3, 4],
- // [11, 12, 13, 14],
- // ) = [[11, 12, 13, 14], [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();
- let from_array = return_array();
- let to_array = return_extra_array();
- let array = array_replace(&[list_array, from_array, to_array])
- .expect("failed to initialize function array_replace");
- let result =
- as_list_array(&array).expect("failed to initialize function
array_replace");
-
- assert_eq!(result.len(), 1);
- let data = vec![
- Some(vec![Some(11), Some(12), Some(13), Some(14)]),
- Some(vec![Some(5), Some(6), Some(7), Some(8)]),
- Some(vec![Some(1), Some(2), Some(3), Some(4)]),
- Some(vec![Some(9), Some(10), Some(11), Some(12)]),
- Some(vec![Some(5), Some(6), Some(7), Some(8)]),
- ];
- let expected = ListArray::from_iter_primitive::<Int64Type, _, _>(data);
- assert_eq!(
- expected,
- result
- .value(0)
- .as_any()
- .downcast_ref::<ListArray>()
- .unwrap()
- .clone()
- );
- }
-
- #[test]
- fn test_array_replace_n() {
- // array_replace_n([3, 1, 2, 3, 2, 3], 3, 4, 2) = [4, 1, 2, 4, 2, 3]
- let list_array = return_array_with_repeating_elements();
- let array = array_replace_n(&[
- list_array,
- Arc::new(Int64Array::from_value(3, 1)),
- Arc::new(Int64Array::from_value(4, 1)),
- Arc::new(Int64Array::from_value(2, 1)),
- ])
- .expect("failed to initialize function array_replace_n");
- let result =
- as_list_array(&array).expect("failed to initialize function
array_replace_n");
-
- assert_eq!(result.len(), 1);
- assert_eq!(
- &[4, 1, 2, 4, 2, 3],
- result
- .value(0)
- .as_any()
- .downcast_ref::<Int64Array>()
- .unwrap()
- .values()
- );
- }
-
- #[test]
- fn test_nested_array_replace_n() {
- // array_replace_n(
- // [[1, 2, 3, 4], [5, 6, 7, 8], [1, 2, 3, 4], [9, 10, 11, 12], [5,
6, 7, 8]],
- // [1, 2, 3, 4],
- // [11, 12, 13, 14],
- // 2,
- // ) = [[11, 12, 13, 14], [5, 6, 7, 8], [11, 12, 13, 14], [9, 10, 11,
12], [5, 6, 7, 8]]
- let list_array = return_nested_array_with_repeating_elements();
- let from_array = return_array();
- let to_array = return_extra_array();
- let array = array_replace_n(&[
- list_array,
- from_array,
- to_array,
- Arc::new(Int64Array::from_value(2, 1)),
- ])
- .expect("failed to initialize function array_replace_n");
- let result =
- as_list_array(&array).expect("failed to initialize function
array_replace_n");
-
- assert_eq!(result.len(), 1);
- let data = vec![
- Some(vec![Some(11), Some(12), Some(13), Some(14)]),
- Some(vec![Some(5), Some(6), Some(7), Some(8)]),
- Some(vec![Some(11), Some(12), Some(13), Some(14)]),
- Some(vec![Some(9), Some(10), Some(11), Some(12)]),
- Some(vec![Some(5), Some(6), Some(7), Some(8)]),
- ];
- let expected = ListArray::from_iter_primitive::<Int64Type, _, _>(data);
- assert_eq!(
- expected,
- result
- .value(0)
- .as_any()
- .downcast_ref::<ListArray>()
- .unwrap()
- .clone()
- );
- }
-
- #[test]
- fn test_array_replace_all() {
- // array_replace_all([3, 1, 2, 3, 2, 3], 3, 4) = [4, 1, 2, 4, 2, 4]
- let list_array = return_array_with_repeating_elements();
- let array = array_replace_all(&[
- list_array,
- Arc::new(Int64Array::from_value(3, 1)),
- Arc::new(Int64Array::from_value(4, 1)),
- ])
- .expect("failed to initialize function array_replace_all");
- let result = as_list_array(&array)
- .expect("failed to initialize function array_replace_all");
-
- assert_eq!(result.len(), 1);
- assert_eq!(
- &[4, 1, 2, 4, 2, 4],
- result
- .value(0)
- .as_any()
- .downcast_ref::<Int64Array>()
- .unwrap()
- .values()
- );
- }
-
- #[test]
- fn test_nested_array_replace_all() {
- // array_replace_all(
- // [[1, 2, 3, 4], [5, 6, 7, 8], [1, 2, 3, 4], [9, 10, 11, 12], [5,
6, 7, 8]],
- // [1, 2, 3, 4],
- // [11, 12, 13, 14],
- // ) = [[11, 12, 13, 14], [5, 6, 7, 8], [11, 12, 13, 14], [9, 10, 11,
12], [5, 6, 7, 8]]
- let list_array = return_nested_array_with_repeating_elements();
- let from_array = return_array();
- let to_array = return_extra_array();
- let array = array_replace_all(&[list_array, from_array, to_array])
- .expect("failed to initialize function array_replace_all");
- let result = as_list_array(&array)
- .expect("failed to initialize function array_replace_all");
-
- assert_eq!(result.len(), 1);
- let data = vec![
- Some(vec![Some(11), Some(12), Some(13), Some(14)]),
- Some(vec![Some(5), Some(6), Some(7), Some(8)]),
- Some(vec![Some(11), Some(12), Some(13), Some(14)]),
- Some(vec![Some(9), Some(10), Some(11), Some(12)]),
- Some(vec![Some(5), Some(6), Some(7), Some(8)]),
- ];
- let expected = ListArray::from_iter_primitive::<Int64Type, _, _>(data);
- assert_eq!(
- expected,
- result
- .value(0)
- .as_any()
- .downcast_ref::<ListArray>()
- .unwrap()
- .clone()
- );
- }
-
#[test]
fn test_array_to_string() {
// array_to_string([1, 2, 3, 4], ',') = 1,2,3,4
@@ -3194,17 +3007,6 @@ mod tests {
make_array(&args).expect("failed to initialize function array")
}
- fn return_extra_array() -> ArrayRef {
- // Returns: [11, 12, 13, 14]
- let args = [
- Arc::new(Int64Array::from(vec![Some(11)])) as ArrayRef,
- Arc::new(Int64Array::from(vec![Some(12)])) as ArrayRef,
- Arc::new(Int64Array::from(vec![Some(13)])) as ArrayRef,
- Arc::new(Int64Array::from(vec![Some(14)])) as ArrayRef,
- ];
- make_array(&args).expect("failed to initialize function array")
- }
-
fn return_nested_array() -> ArrayRef {
// Returns: [[1, 2, 3, 4], [5, 6, 7, 8]]
let args = [
diff --git a/datafusion/sqllogictest/test_files/array.slt
b/datafusion/sqllogictest/test_files/array.slt
index f83ed5a95f..ad81f37e07 100644
--- a/datafusion/sqllogictest/test_files/array.slt
+++ b/datafusion/sqllogictest/test_files/array.slt
@@ -1605,19 +1605,35 @@ select array_positions(column1, make_array(4, 5, 6)),
array_positions(make_array
# array_replace scalar function #1
query ???
-select array_replace(make_array(1, 2, 3, 4), 2, 3),
array_replace(make_array(1, 4, 4, 5, 4, 6, 7), 4, 0),
array_replace(make_array(1, 2, 3), 4, 0);
+select
+ array_replace(make_array(1, 2, 3, 4), 2, 3),
+ array_replace(make_array(1, 4, 4, 5, 4, 6, 7), 4, 0),
+ array_replace(make_array(1, 2, 3), 4, 0);
----
[1, 3, 3, 4] [1, 0, 4, 5, 4, 6, 7] [1, 2, 3]
# array_replace scalar function #2 (element is list)
query ??
-select array_replace(make_array([1, 2, 3], [4, 5, 6], [5, 5, 5], [4, 5, 6],
[7, 8, 9]), [4, 5, 6], [1, 1, 1]), array_replace(make_array([1, 3, 2], [2, 3,
4], [2, 3, 4], [5, 3, 1], [1, 3, 2]), [2, 3, 4], [3, 1, 4]);
+select
+ array_replace(
+ make_array([1, 2, 3], [4, 5, 6], [5, 5, 5], [4, 5, 6], [7, 8, 9]),
+ [4, 5, 6],
+ [1, 1, 1]
+ ),
+ array_replace(
+ make_array([1, 3, 2], [2, 3, 4], [2, 3, 4], [5, 3, 1], [1, 3, 2]),
+ [2, 3, 4],
+ [3, 1, 4]
+ );
----
[[1, 2, 3], [1, 1, 1], [5, 5, 5], [4, 5, 6], [7, 8, 9]] [[1, 3, 2], [3, 1, 4],
[2, 3, 4], [5, 3, 1], [1, 3, 2]]
# list_replace scalar function #3 (function alias `list_replace`)
query ???
-select list_replace(make_array(1, 2, 3, 4), 2, 3), list_replace(make_array(1,
4, 4, 5, 4, 6, 7), 4, 0), list_replace(make_array(1, 2, 3), 4, 0);
+select list_replace(
+ make_array(1, 2, 3, 4), 2, 3),
+ list_replace(make_array(1, 4, 4, 5, 4, 6, 7), 4, 0),
+ list_replace(make_array(1, 2, 3), 4, 0);
----
[1, 3, 3, 4] [1, 0, 4, 5, 4, 6, 7] [1, 2, 3]
@@ -1641,7 +1657,11 @@ select array_replace(column1, column2, column3) from
nested_arrays_with_repeatin
# array_replace scalar function with columns and scalars #1
query ???
-select array_replace(make_array(1, 2, 2, 4, 5, 4, 4, 7, 7, 10, 7, 8), column2,
column3), array_replace(column1, 1, column3), array_replace(column1, column2,
4) from arrays_with_repeating_elements;
+select
+ array_replace(make_array(1, 2, 2, 4, 5, 4, 4, 7, 7, 10, 7, 8), column2,
column3),
+ array_replace(column1, 1, column3),
+ array_replace(column1, column2, 4)
+from arrays_with_repeating_elements;
----
[1, 4, 2, 4, 5, 4, 4, 7, 7, 10, 7, 8] [4, 2, 1, 3, 2, 2, 1, 3, 2, 3] [1, 4, 1,
3, 2, 2, 1, 3, 2, 3]
[1, 2, 2, 7, 5, 4, 4, 7, 7, 10, 7, 8] [4, 4, 5, 5, 6, 5, 5, 5, 4, 4] [4, 4, 5,
5, 6, 5, 5, 5, 4, 4]
@@ -1650,7 +1670,16 @@ select array_replace(make_array(1, 2, 2, 4, 5, 4, 4, 7,
7, 10, 7, 8), column2, c
# array_replace scalar function with columns and scalars #2 (element is list)
query ???
-select array_replace(make_array([1, 2, 3], [4, 5, 6], [4, 5, 6], [10, 11, 12],
[13, 14, 15], [10, 11, 12], [10, 11, 12], [19, 20, 21], [19, 20, 21], [28, 29,
30], [19, 20, 21], [22, 23, 24]), column2, column3), array_replace(column1,
make_array(1, 2, 3), column3), array_replace(column1, column2, make_array(11,
12, 13)) from nested_arrays_with_repeating_elements;
+select
+ array_replace(
+ make_array(
+ [1, 2, 3], [4, 5, 6], [4, 5, 6], [10, 11, 12], [13, 14, 15], [10, 11,
12], [10, 11, 12], [19, 20, 21], [19, 20, 21], [28, 29, 30], [19, 20, 21], [22,
23, 24]),
+ column2,
+ column3
+ ),
+ array_replace(column1, make_array(1, 2, 3), column3),
+ array_replace(column1, column2, make_array(11, 12, 13))
+from nested_arrays_with_repeating_elements;
----
[[1, 2, 3], [10, 11, 12], [4, 5, 6], [10, 11, 12], [13, 14, 15], [10, 11, 12],
[10, 11, 12], [19, 20, 21], [19, 20, 21], [28, 29, 30], [19, 20, 21], [22, 23,
24]] [[10, 11, 12], [4, 5, 6], [1, 2, 3], [7, 8, 9], [4, 5, 6], [4, 5, 6], [1,
2, 3], [7, 8, 9], [4, 5, 6], [7, 8, 9]] [[1, 2, 3], [11, 12, 13], [1, 2, 3],
[7, 8, 9], [4, 5, 6], [4, 5, 6], [1, 2, 3], [7, 8, 9], [4, 5, 6], [7, 8, 9]]
[[1, 2, 3], [4, 5, 6], [4, 5, 6], [19, 20, 21], [13, 14, 15], [10, 11, 12],
[10, 11, 12], [19, 20, 21], [19, 20, 21], [28, 29, 30], [19, 20, 21], [22, 23,
24]] [[10, 11, 12], [10, 11, 12], [13, 14, 15], [13, 14, 15], [16, 17, 18],
[13, 14, 15], [13, 14, 15], [13, 14, 15], [10, 11, 12], [10, 11, 12]] [[11, 12,
13], [10, 11, 12], [13, 14, 15], [13, 14, 15], [16, 17, 18], [13, 14, 15], [13,
14, 15], [13, 14, 15], [10, 11, 12], [10, 11, 12]]
@@ -1661,25 +1690,45 @@ select array_replace(make_array([1, 2, 3], [4, 5, 6],
[4, 5, 6], [10, 11, 12], [
# array_replace_n scalar function #1
query ???
-select array_replace_n(make_array(1, 2, 3, 4), 2, 3, 2),
array_replace_n(make_array(1, 4, 4, 5, 4, 6, 7), 4, 0, 2),
array_replace_n(make_array(1, 2, 3), 4, 0, 3);
+select
+ array_replace_n(make_array(1, 2, 3, 4), 2, 3, 2),
+ array_replace_n(make_array(1, 4, 4, 5, 4, 6, 7), 4, 0, 2),
+ array_replace_n(make_array(1, 2, 3), 4, 0, 3);
----
[1, 3, 3, 4] [1, 0, 0, 5, 4, 6, 7] [1, 2, 3]
# array_replace_n scalar function #2 (element is list)
query ??
-select array_replace_n(make_array([1, 2, 3], [4, 5, 6], [5, 5, 5], [4, 5, 6],
[7, 8, 9]), [4, 5, 6], [1, 1, 1], 2), array_replace_n(make_array([1, 3, 2], [2,
3, 4], [2, 3, 4], [5, 3, 1], [1, 3, 2]), [2, 3, 4], [3, 1, 4], 2);
+select
+ array_replace_n(
+ make_array([1, 2, 3], [4, 5, 6], [5, 5, 5], [4, 5, 6], [7, 8, 9]),
+ [4, 5, 6],
+ [1, 1, 1],
+ 2
+ ),
+ array_replace_n(
+ make_array([1, 3, 2], [2, 3, 4], [2, 3, 4], [5, 3, 1], [1, 3, 2]),
+ [2, 3, 4],
+ [3, 1, 4],
+ 2
+ );
----
[[1, 2, 3], [1, 1, 1], [5, 5, 5], [1, 1, 1], [7, 8, 9]] [[1, 3, 2], [3, 1, 4],
[3, 1, 4], [5, 3, 1], [1, 3, 2]]
# list_replace_n scalar function #3 (function alias `array_replace_n`)
query ???
-select list_replace_n(make_array(1, 2, 3, 4), 2, 3, 2),
list_replace_n(make_array(1, 4, 4, 5, 4, 6, 7), 4, 0, 2),
list_replace_n(make_array(1, 2, 3), 4, 0, 3);
+select
+ list_replace_n(make_array(1, 2, 3, 4), 2, 3, 2),
+ list_replace_n(make_array(1, 4, 4, 5, 4, 6, 7), 4, 0, 2),
+ list_replace_n(make_array(1, 2, 3), 4, 0, 3);
----
[1, 3, 3, 4] [1, 0, 0, 5, 4, 6, 7] [1, 2, 3]
# array_replace_n scalar function with columns #1
query ?
-select array_replace_n(column1, column2, column3, column4) from
arrays_with_repeating_elements;
+select
+ array_replace_n(column1, column2, column3, column4)
+from arrays_with_repeating_elements;
----
[1, 4, 1, 3, 4, 4, 1, 3, 2, 3]
[7, 7, 5, 5, 6, 5, 5, 5, 4, 4]
@@ -1688,7 +1737,9 @@ select array_replace_n(column1, column2, column3,
column4) from arrays_with_repe
# array_replace_n scalar function with columns #2 (element is list)
query ?
-select array_replace_n(column1, column2, column3, column4) from
nested_arrays_with_repeating_elements;
+select
+ array_replace_n(column1, column2, column3, column4)
+from nested_arrays_with_repeating_elements;
----
[[1, 2, 3], [10, 11, 12], [1, 2, 3], [7, 8, 9], [10, 11, 12], [10, 11, 12],
[1, 2, 3], [7, 8, 9], [4, 5, 6], [7, 8, 9]]
[[19, 20, 21], [19, 20, 21], [13, 14, 15], [13, 14, 15], [16, 17, 18], [13,
14, 15], [13, 14, 15], [13, 14, 15], [10, 11, 12], [10, 11, 12]]
@@ -1697,7 +1748,12 @@ select array_replace_n(column1, column2, column3,
column4) from nested_arrays_wi
# array_replace_n scalar function with columns and scalars #1
query ????
-select array_replace_n(make_array(1, 2, 2, 4, 5, 4, 4, 7, 7, 10, 7, 8),
column2, column3, column4), array_replace_n(column1, 1, column3, column4),
array_replace_n(column1, column2, 4, column4), array_replace_n(column1,
column2, column3, 2) from arrays_with_repeating_elements;
+select
+ array_replace_n(make_array(1, 2, 2, 4, 5, 4, 4, 7, 7, 10, 7, 8), column2,
column3, column4),
+ array_replace_n(column1, 1, column3, column4),
+ array_replace_n(column1, column2, 4, column4),
+ array_replace_n(column1, column2, column3, 2)
+from arrays_with_repeating_elements;
----
[1, 4, 4, 4, 5, 4, 4, 7, 7, 10, 7, 8] [4, 2, 4, 3, 2, 2, 4, 3, 2, 3] [1, 4, 1,
3, 4, 4, 1, 3, 2, 3] [1, 4, 1, 3, 4, 2, 1, 3, 2, 3]
[1, 2, 2, 7, 5, 7, 4, 7, 7, 10, 7, 8] [4, 4, 5, 5, 6, 5, 5, 5, 4, 4] [4, 4, 5,
5, 6, 5, 5, 5, 4, 4] [7, 7, 5, 5, 6, 5, 5, 5, 4, 4]
@@ -1706,7 +1762,18 @@ select array_replace_n(make_array(1, 2, 2, 4, 5, 4, 4,
7, 7, 10, 7, 8), column2,
# array_replace_n scalar function with columns and scalars #2 (element is list)
query ????
-select array_replace_n(make_array([7, 8, 9], [2, 1, 3], [1, 5, 6], [10, 11,
12], [2, 1, 3], [7, 8, 9], [4, 5, 6]), column2, column3, column4),
array_replace_n(column1, make_array(1, 2, 3), column3, column4),
array_replace_n(column1, column2, make_array(11, 12, 13), column4),
array_replace_n(column1, column2, column3, 2) from
nested_arrays_with_repeating_elements;
+select
+ array_replace_n(
+ make_array(
+ [7, 8, 9], [2, 1, 3], [1, 5, 6], [10, 11, 12], [2, 1, 3], [7, 8, 9], [4,
5, 6]),
+ column2,
+ column3,
+ column4
+ ),
+ array_replace_n(column1, make_array(1, 2, 3), column3, column4),
+ array_replace_n(column1, column2, make_array(11, 12, 13), column4),
+ array_replace_n(column1, column2, column3, 2)
+from nested_arrays_with_repeating_elements;
----
[[7, 8, 9], [2, 1, 3], [1, 5, 6], [10, 11, 12], [2, 1, 3], [7, 8, 9], [10, 11,
12]] [[10, 11, 12], [4, 5, 6], [10, 11, 12], [7, 8, 9], [4, 5, 6], [4, 5, 6],
[10, 11, 12], [7, 8, 9], [4, 5, 6], [7, 8, 9]] [[1, 2, 3], [11, 12, 13], [1, 2,
3], [7, 8, 9], [11, 12, 13], [11, 12, 13], [1, 2, 3], [7, 8, 9], [4, 5, 6], [7,
8, 9]] [[1, 2, 3], [10, 11, 12], [1, 2, 3], [7, 8, 9], [10, 11, 12], [4, 5, 6],
[1, 2, 3], [7, 8, 9], [4, 5, 6], [7, 8, 9]]
[[7, 8, 9], [2, 1, 3], [1, 5, 6], [19, 20, 21], [2, 1, 3], [7, 8, 9], [4, 5,
6]] [[10, 11, 12], [10, 11, 12], [13, 14, 15], [13, 14, 15], [16, 17, 18], [13,
14, 15], [13, 14, 15], [13, 14, 15], [10, 11, 12], [10, 11, 12]] [[11, 12, 13],
[11, 12, 13], [13, 14, 15], [13, 14, 15], [16, 17, 18], [13, 14, 15], [13, 14,
15], [13, 14, 15], [10, 11, 12], [10, 11, 12]] [[19, 20, 21], [19, 20, 21],
[13, 14, 15], [13, 14, 15], [16, 17, 18], [13, 14, 15], [13, 14, 15], [13, 14,
15], [10, 11, 12], [1 [...]
@@ -1717,25 +1784,43 @@ select array_replace_n(make_array([7, 8, 9], [2, 1, 3],
[1, 5, 6], [10, 11, 12],
# array_replace_all scalar function #1
query ???
-select array_replace_all(make_array(1, 2, 3, 4), 2, 3),
array_replace_all(make_array(1, 4, 4, 5, 4, 6, 7), 4, 0),
array_replace_all(make_array(1, 2, 3), 4, 0);
+select
+ array_replace_all(make_array(1, 2, 3, 4), 2, 3),
+ array_replace_all(make_array(1, 4, 4, 5, 4, 6, 7), 4, 0),
+ array_replace_all(make_array(1, 2, 3), 4, 0);
----
[1, 3, 3, 4] [1, 0, 0, 5, 0, 6, 7] [1, 2, 3]
# array_replace_all scalar function #2 (element is list)
query ??
-select array_replace_all(make_array([1, 2, 3], [4, 5, 6], [5, 5, 5], [4, 5,
6], [7, 8, 9]), [4, 5, 6], [1, 1, 1]), array_replace_all(make_array([1, 3, 2],
[2, 3, 4], [2, 3, 4], [5, 3, 1], [1, 3, 2]), [2, 3, 4], [3, 1, 4]);
+select
+ array_replace_all(
+ make_array([1, 2, 3], [4, 5, 6], [5, 5, 5], [4, 5, 6], [7, 8, 9]),
+ [4, 5, 6],
+ [1, 1, 1]
+ ),
+ array_replace_all(
+ make_array([1, 3, 2], [2, 3, 4], [2, 3, 4], [5, 3, 1], [1, 3, 2]),
+ [2, 3, 4],
+ [3, 1, 4]
+ );
----
[[1, 2, 3], [1, 1, 1], [5, 5, 5], [1, 1, 1], [7, 8, 9]] [[1, 3, 2], [3, 1, 4],
[3, 1, 4], [5, 3, 1], [1, 3, 2]]
# list_replace_all scalar function #3 (function alias `array_replace_all`)
query ???
-select list_replace_all(make_array(1, 2, 3, 4), 2, 3),
list_replace_all(make_array(1, 4, 4, 5, 4, 6, 7), 4, 0),
list_replace_all(make_array(1, 2, 3), 4, 0);
+select
+ list_replace_all(make_array(1, 2, 3, 4), 2, 3),
+ list_replace_all(make_array(1, 4, 4, 5, 4, 6, 7), 4, 0),
+ list_replace_all(make_array(1, 2, 3), 4, 0);
----
[1, 3, 3, 4] [1, 0, 0, 5, 0, 6, 7] [1, 2, 3]
# array_replace_all scalar function with columns #1
query ?
-select array_replace_all(column1, column2, column3) from
arrays_with_repeating_elements;
+select
+ array_replace_all(column1, column2, column3)
+from arrays_with_repeating_elements;
----
[1, 4, 1, 3, 4, 4, 1, 3, 4, 3]
[7, 7, 5, 5, 6, 5, 5, 5, 7, 7]
@@ -1744,7 +1829,9 @@ select array_replace_all(column1, column2, column3) from
arrays_with_repeating_e
# array_replace_all scalar function with columns #2 (element is list)
query ?
-select array_replace_all(column1, column2, column3) from
nested_arrays_with_repeating_elements;
+select
+ array_replace_all(column1, column2, column3)
+from nested_arrays_with_repeating_elements;
----
[[1, 2, 3], [10, 11, 12], [1, 2, 3], [7, 8, 9], [10, 11, 12], [10, 11, 12],
[1, 2, 3], [7, 8, 9], [10, 11, 12], [7, 8, 9]]
[[19, 20, 21], [19, 20, 21], [13, 14, 15], [13, 14, 15], [16, 17, 18], [13,
14, 15], [13, 14, 15], [13, 14, 15], [19, 20, 21], [19, 20, 21]]
@@ -1753,7 +1840,11 @@ select array_replace_all(column1, column2, column3) from
nested_arrays_with_repe
# array_replace_all scalar function with columns and scalars #1
query ???
-select array_replace_all(make_array(1, 2, 2, 4, 5, 4, 4, 7, 7, 10, 7, 8),
column2, column3), array_replace_all(column1, 1, column3),
array_replace_all(column1, column2, 4) from arrays_with_repeating_elements;
+select
+ array_replace_all(make_array(1, 2, 2, 4, 5, 4, 4, 7, 7, 10, 7, 8), column2,
column3),
+ array_replace_all(column1, 1, column3),
+ array_replace_all(column1, column2, 4)
+from arrays_with_repeating_elements;
----
[1, 4, 4, 4, 5, 4, 4, 7, 7, 10, 7, 8] [4, 2, 4, 3, 2, 2, 4, 3, 2, 3] [1, 4, 1,
3, 4, 4, 1, 3, 4, 3]
[1, 2, 2, 7, 5, 7, 7, 7, 7, 10, 7, 8] [4, 4, 5, 5, 6, 5, 5, 5, 4, 4] [4, 4, 5,
5, 6, 5, 5, 5, 4, 4]
@@ -1762,7 +1853,15 @@ select array_replace_all(make_array(1, 2, 2, 4, 5, 4, 4,
7, 7, 10, 7, 8), column
# array_replace_all scalar function with columns and scalars #2 (element is
list)
query ???
-select array_replace_all(make_array([1, 2, 3], [4, 5, 6], [4, 5, 6], [10, 11,
12], [13, 14, 15], [10, 11, 12], [10, 11, 12], [19, 20, 21], [19, 20, 21], [28,
29, 30], [19, 20, 21], [22, 23, 24]), column2, column3),
array_replace_all(column1, make_array(1, 2, 3), column3),
array_replace_all(column1, column2, make_array(11, 12, 13)) from
nested_arrays_with_repeating_elements;
+select
+ array_replace_all(
+ make_array([1, 2, 3], [4, 5, 6], [4, 5, 6], [10, 11, 12], [13, 14, 15],
[10, 11, 12], [10, 11, 12], [19, 20, 21], [19, 20, 21], [28, 29, 30], [19, 20,
21], [22, 23, 24]),
+ column2,
+ column3
+ ),
+ array_replace_all(column1, make_array(1, 2, 3), column3),
+ array_replace_all(column1, column2, make_array(11, 12, 13))
+from nested_arrays_with_repeating_elements;
----
[[1, 2, 3], [10, 11, 12], [10, 11, 12], [10, 11, 12], [13, 14, 15], [10, 11,
12], [10, 11, 12], [19, 20, 21], [19, 20, 21], [28, 29, 30], [19, 20, 21], [22,
23, 24]] [[10, 11, 12], [4, 5, 6], [10, 11, 12], [7, 8, 9], [4, 5, 6], [4, 5,
6], [10, 11, 12], [7, 8, 9], [4, 5, 6], [7, 8, 9]] [[1, 2, 3], [11, 12, 13],
[1, 2, 3], [7, 8, 9], [11, 12, 13], [11, 12, 13], [1, 2, 3], [7, 8, 9], [11,
12, 13], [7, 8, 9]]
[[1, 2, 3], [4, 5, 6], [4, 5, 6], [19, 20, 21], [13, 14, 15], [19, 20, 21],
[19, 20, 21], [19, 20, 21], [19, 20, 21], [28, 29, 30], [19, 20, 21], [22, 23,
24]] [[10, 11, 12], [10, 11, 12], [13, 14, 15], [13, 14, 15], [16, 17, 18],
[13, 14, 15], [13, 14, 15], [13, 14, 15], [10, 11, 12], [10, 11, 12]] [[11, 12,
13], [11, 12, 13], [13, 14, 15], [13, 14, 15], [16, 17, 18], [13, 14, 15], [13,
14, 15], [13, 14, 15], [11, 12, 13], [11, 12, 13]]