Skip to content
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

[Feature]implement Lambda array_filter() #10323

Merged
merged 3 commits into from
Sep 6, 2022

Conversation

fzhedu
Copy link
Contributor

@fzhedu fzhedu commented Aug 23, 2022

What type of PR is this:

  • bug
  • feature
  • enhancement
  • refactor
  • others

Which issues of this PR fixes :

Fixes #

Problem Summary(Required) :

array_filter(array, array_bool) use array_bool to filter array, where the array_bool item is not null or not zero.
if array_bool.size() != array.size(), the result array is decided by the valid items within min(array_bool, array).
if the array_bool is NULL, it does filter all elements by design.
if any of array or array_bool is const null, return null directly.

for example:

array=[11,2], array_bool=[0,1,null,1], res = [2].
array=[11,2], array_bool=[1], res = [11].
array=[11,2], array_bool=NULL, res = [].
array=null, array_bool[], res = NULL.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • I have added user document for my new feature or new function

@fzhedu fzhedu force-pushed the lambdaArrayFilter branch 3 times, most recently from 7b8f704 to 04a5f2d Compare September 3, 2022 15:06
@wanpengfei-git
Copy link
Collaborator

[FE PR Coverage Check]

😍 pass : 51 / 53 (96.23%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/sql/analyzer/FunctionAnalyzer.java 33 35 94.29% [157, 158]
🔵 com/starrocks/sql/analyzer/ExpressionAnalyzer.java 18 18 100.00% []

@sonarcloud
Copy link

sonarcloud bot commented Sep 6, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@@ -27,7 +27,7 @@ public static void analyze(FunctionCallExpr functionCallExpr) {
}

FunctionName fnName = functionCallExpr.getFnName();
if (fnName.getFunction().equalsIgnoreCase(FunctionSet.DATE_TRUNC)) {
if (fnName.getFunction().equals(FunctionSet.DATE_TRUNC)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggested by #10323 (comment)

@wanpengfei-git wanpengfei-git added the Approved Ready to merge label Sep 6, 2022
@wanpengfei-git
Copy link
Collaborator

run starrocks_admit_test

@murphyatwork murphyatwork merged commit 3073af8 into StarRocks:main Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved Ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants