Skip to content

feat(query): Support array lambda function #12217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 30, 2023

Conversation

b41sh
Copy link
Member

@b41sh b41sh commented Jul 26, 2023

I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/

Summary

Support array lambda function

  • array_transform
  • array_apply
  • array_filter

for example

mysql> select array_transform([1, 2, NULL, 3], x -> x + 1);
+------------------------------------------------+
| array_transform([1, 2, null, 3], x -> (x + 1)) |
+------------------------------------------------+
| [2,3,NULL,4]                                   |
+------------------------------------------------+
1 row in set (0.04 sec)
Read 1 rows, 1.00 B in 0.006 sec., 181.05 rows/sec., 181.05 B/sec.

mysql> select array_apply(['data', 'a', 'b'], data -> CONCAT(data, 'bend'));
+---------------------------------------------------------------+
| array_apply(['data', 'a', 'b'], data -> concat(data, 'bend')) |
+---------------------------------------------------------------+
| ['databend','abend','bbend']                                  |
+---------------------------------------------------------------+
1 row in set (0.03 sec)
Read 1 rows, 1.00 B in 0.005 sec., 183.59 rows/sec., 183.59 B/sec.

mysql> select array_filter(['Hello', 'abc World'], x -> x LIKE '%World%');
+---------------------------------------------------------------+
| array_filter(['hello', 'abc world'], x -> (x like '%world%')) |
+---------------------------------------------------------------+
| ['abc World']                                                 |
+---------------------------------------------------------------+
1 row in set (0.03 sec)
Read 1 rows, 1.00 B in 0.008 sec., 128.79 rows/sec., 128.79 B/sec.

part of #7931


This change is Reviewable

@vercel
Copy link

vercel bot commented Jul 26, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
databend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 30, 2023 4:59am

@b41sh b41sh marked this pull request as ready for review July 28, 2023 08:53
@github-actions github-actions bot added the pr-feature this PR introduces a new feature to the codebase label Jul 28, 2023
@andylokandy andylokandy requested a review from leiysky July 28, 2023 10:59
@BohuTANG
Copy link
Member

Need a document for this cool feature. cc @soyeric128

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-feature this PR introduces a new feature to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants