Skip to content

Commit

Permalink
Use not_distinct
Browse files Browse the repository at this point in the history
  • Loading branch information
alamb committed Nov 6, 2023
1 parent c6dabcf commit acbffa0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion datafusion/physical-expr/src/array_expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,8 @@ fn general_replace(
}
_ => {
let from_arr = Scalar::new(from_array_row);
arrow_ord::cmp::eq(&list_array_row, &from_arr)?
// use not_distinct so NULL = NULL
arrow_ord::cmp::not_distinct(&list_array_row, &from_arr)?
}
};

Expand Down
4 changes: 2 additions & 2 deletions datafusion/sqllogictest/test_files/array.slt
Original file line number Diff line number Diff line change
Expand Up @@ -1744,15 +1744,15 @@ create table t as values


# ([3, 1, NULL, 3], 3, 4, 2) => [4, 1, NULL, 4] NULL not matched
# ([3, 1, NULL, 3], NULL, 5, 2) => [3, 1, NULL, 3] NULL not replaced (not eq)
# ([3, 1, NULL, 3], NULL, 5, 2) => [3, 1, NULL, 3] NULL is replaced with 5
# ([NULL], 3, 2, 1) => NULL
# ([3, 1, 3], 3, NULL, 1) => [NULL, 1 3]

query ?III?
select column1, column2, column3, column4, array_replace_n(column1, column2, column3, column4) from t;
----
[3, 1, , 3] 3 4 2 [4, 1, , 4]
[3, 1, , 3] NULL 5 2 [3, 1, , 3]
[3, 1, , 3] NULL 5 2 [3, 1, 5, 3]
NULL 3 2 1 NULL
[3, 1, 3] 3 NULL 1 [, 1, 3]

Expand Down

0 comments on commit acbffa0

Please sign in to comment.