-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Enhancement] handle const column in array_filter (#51363)
Signed-off-by: silverbullet233 <3675229+silverbullet233@users.noreply.github.com>
- Loading branch information
1 parent
f49cb4f
commit 0c35297
Showing
3 changed files
with
253 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
-- name: test_array_filter | ||
CREATE TABLE `t` ( | ||
`k` bigint(20) NOT NULL COMMENT "", | ||
`arr_0` array<bigint(20)> NOT NULL COMMENT "", | ||
`arr_1` array<bigint(20)> NULL COMMENT "", | ||
`arr_2` array<bigint(20)> NULL COMMENT "" | ||
) ENGINE=OLAP | ||
DUPLICATE KEY(`k`) | ||
DISTRIBUTED BY RANDOM BUCKETS 1 | ||
PROPERTIES ( | ||
"replication_num" = "1" | ||
); | ||
-- result: | ||
-- !result | ||
insert into t values (1,[1,2],[1,2],[0,1]),(2,[1,2],null,[1,1]),(3,[1,2],[1,2],null),(4,[1,2],[null,null],[null,null]),(5,[1],[1,2],[0,0,1]); | ||
-- result: | ||
-- !result | ||
select array_filter(arr_0, arr_2) from t order by k; | ||
-- result: | ||
[2] | ||
[1,2] | ||
[] | ||
[] | ||
[] | ||
-- !result | ||
select array_filter(arr_1, arr_2) from t order by k; | ||
-- result: | ||
[2] | ||
None | ||
[] | ||
[] | ||
[] | ||
-- !result | ||
select array_filter(arr_0,[0,0,0,1]) from t order by k; | ||
-- result: | ||
[] | ||
[] | ||
[] | ||
[] | ||
[] | ||
-- !result | ||
select array_filter(arr_0,[1,0,1]) from t order by k; | ||
-- result: | ||
[1] | ||
[1] | ||
[1] | ||
[1] | ||
[1] | ||
-- !result | ||
select array_filter(arr_0,null) from t order by k; | ||
-- result: | ||
[] | ||
[] | ||
[] | ||
[] | ||
[] | ||
-- !result | ||
select array_filter(arr_1,null) from t order by k; | ||
-- result: | ||
[] | ||
None | ||
[] | ||
[] | ||
[] | ||
-- !result | ||
select array_filter([1,2,3,4],arr_2) from t order by k; | ||
-- result: | ||
[2] | ||
[1,2] | ||
[] | ||
[] | ||
[3] | ||
-- !result | ||
select array_filter(null, arr_2) from t order by k; | ||
-- result: | ||
None | ||
None | ||
None | ||
None | ||
None | ||
-- !result | ||
select array_filter([1,2,3,4],[0,0,1,1]) from t; | ||
-- result: | ||
[3,4] | ||
[3,4] | ||
[3,4] | ||
[3,4] | ||
[3,4] | ||
-- !result | ||
select array_filter(null, null) from t; | ||
-- result: | ||
None | ||
None | ||
None | ||
None | ||
None | ||
-- !result | ||
select array_filter([1,2,3,4],null) from t; | ||
-- result: | ||
[] | ||
[] | ||
[] | ||
[] | ||
[] | ||
-- !result | ||
select array_filter(null, [1,0,1,null]) from t; | ||
-- result: | ||
None | ||
None | ||
None | ||
None | ||
None | ||
-- !result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
-- name: test_array_filter | ||
CREATE TABLE `t` ( | ||
`k` bigint(20) NOT NULL COMMENT "", | ||
`arr_0` array<bigint(20)> NOT NULL COMMENT "", | ||
`arr_1` array<bigint(20)> NULL COMMENT "", | ||
`arr_2` array<bigint(20)> NULL COMMENT "" | ||
) ENGINE=OLAP | ||
DUPLICATE KEY(`k`) | ||
DISTRIBUTED BY RANDOM BUCKETS 1 | ||
PROPERTIES ( | ||
"replication_num" = "1" | ||
); | ||
insert into t values (1,[1,2],[1,2],[0,1]),(2,[1,2],null,[1,1]),(3,[1,2],[1,2],null),(4,[1,2],[null,null],[null,null]),(5,[1],[1,2],[0,0,1]); | ||
|
||
select array_filter(arr_0, arr_2) from t order by k; | ||
select array_filter(arr_1, arr_2) from t order by k; | ||
select array_filter(arr_0,[0,0,0,1]) from t order by k; | ||
select array_filter(arr_0,[1,0,1]) from t order by k; | ||
select array_filter(arr_0,null) from t order by k; | ||
select array_filter(arr_1,null) from t order by k; | ||
select array_filter([1,2,3,4],arr_2) from t order by k; | ||
select array_filter(null, arr_2) from t order by k; | ||
select array_filter([1,2,3,4],[0,0,1,1]) from t; | ||
select array_filter(null, null) from t; | ||
select array_filter([1,2,3,4],null) from t; | ||
select array_filter(null, [1,0,1,null]) from t; |