-
Notifications
You must be signed in to change notification settings - Fork 752
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(query): add string function: split and split_part (#13303)
* feat(query): add string function: split and split_part * add some test
- Loading branch information
Showing
5 changed files
with
233 additions
and
0 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
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
88 changes: 88 additions & 0 deletions
88
tests/sqllogictests/suites/query/02_function/02_0067_function_string_split
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,88 @@ | ||
query T | ||
select split('127.0.0.1', '.'); | ||
---- | ||
['127','0','0','1'] | ||
|
||
query T | ||
select split('|', '|'); | ||
---- | ||
['',''] | ||
|
||
query T | ||
select split('ab', ''); | ||
---- | ||
['','a','b',''] | ||
|
||
query T | ||
select split_part('ab', '', 1); | ||
---- | ||
(empty) | ||
|
||
query T | ||
select split_part('ab', '', 2); | ||
---- | ||
a | ||
|
||
query T | ||
select split_part('|', '|', 1); | ||
---- | ||
(empty) | ||
|
||
query T | ||
select split_part(null, null, 1); | ||
---- | ||
NULL | ||
|
||
query T | ||
select split(null, null); | ||
---- | ||
NULL | ||
|
||
|
||
query TT | ||
select * from | ||
(select 0, split_part('11.22.33', '.', 0) UNION | ||
select 1, split_part('11.22.33', '.', 1) UNION | ||
select 2, split_part('11.22.33', '.', 2) UNION | ||
select 3, split_part('11.22.33', '.', 3) UNION | ||
select 4, split_part('11.22.33', '.', 4) UNION | ||
select -1, split_part('11.22.33', '.', -1) UNION | ||
select -2, split_part('11.22.33', '.', -2) UNION | ||
select -3, split_part('11.22.33', '.', -3) UNION | ||
select -4, split_part('11.22.33', '.', -4)) order by `0`; | ||
---- | ||
-4 (empty) | ||
-3 11 | ||
-2 22 | ||
-1 33 | ||
0 11 | ||
1 11 | ||
2 22 | ||
3 33 | ||
4 (empty) | ||
|
||
statement ok | ||
drop table if exists t; | ||
|
||
statement ok | ||
create table t(c1 string); | ||
|
||
statement ok | ||
insert into t values('127.0.0.1'), ('127.0.0.2'), ('192.168.1.3.2222') | ||
|
||
query T | ||
select split(c1, '.') from t order by c1 | ||
---- | ||
['127','0','0','1'] | ||
['127','0','0','2'] | ||
['192','168','1','3','2222'] | ||
|
||
query T | ||
select split_part(c1, '.', -5), split_part(c1, '.', -4), split_part(c1, '.', 0), split_part(c1, '.', 1), split_part(c1, '.', 4), split_part(c1, '.', 5) from t order by c1 | ||
---- | ||
(empty) 127 127 127 1 (empty) | ||
(empty) 127 127 127 2 (empty) | ||
192 168 192 192 3 2222 | ||
|
||
statement ok | ||
drop table t; |
ce6e979
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
databend – ./
databend.vercel.app
databend-databend.vercel.app
databend-git-main-databend.vercel.app
databend.rs
databend.org