-
Notifications
You must be signed in to change notification settings - Fork 155
Add lambda function and array related functions #3584
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
Open
xinyual
wants to merge
25
commits into
opensearch-project:main
Choose a base branch
from
xinyual:addCollection
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
06fe11a
add forall
xinyual 31733dd
add filter/exists/
xinyual e305747
add reduce
xinyual 8a9d024
add return type inference
xinyual 689534b
fix exists
xinyual 2cc41d8
add map for lambda
xinyual bacccdf
add infer for reduce
xinyual 013f7df
add java doc
xinyual 9fb35fe
merge from main
xinyual 3d465e6
revert useless change
xinyual 8051c52
renane
xinyual 1b99ce5
fix g4
xinyual b5c4a03
fix g4
xinyual 794df29
fix g4 file
xinyual f87787b
merge from main
xinyual fd97885
apply spotless
xinyual 9cca2fc
merge from main
xinyual 241a57c
test
xinyual c90f53d
use builtin operator
xinyual a22a524
add array_length with test
xinyual 7f9c6ec
optimize reduce
xinyual 17a19d3
add UT
xinyual 70d6a7a
fix reduce and add doc
xinyual 49c3794
revert useless change
xinyual b85aafa
add doc
xinyual File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
47 changes: 47 additions & 0 deletions
47
core/src/main/java/org/opensearch/sql/ast/expression/LambdaFunction.java
This file contains hidden or 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,47 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.sql.ast.expression; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import org.opensearch.sql.ast.AbstractNodeVisitor; | ||
|
||
/** | ||
* Expression node of lambda function. Params include function name (@funcName) and function | ||
* arguments (@funcArgs) | ||
*/ | ||
@Getter | ||
@EqualsAndHashCode(callSuper = false) | ||
@RequiredArgsConstructor | ||
public class LambdaFunction extends UnresolvedExpression { | ||
private final UnresolvedExpression function; | ||
private final List<QualifiedName> funcArgs; | ||
|
||
@Override | ||
public List<UnresolvedExpression> getChild() { | ||
List<UnresolvedExpression> children = new ArrayList<>(); | ||
children.add(function); | ||
children.addAll(funcArgs); | ||
return children; | ||
} | ||
|
||
@Override | ||
public <R, C> R accept(AbstractNodeVisitor<R, C> nodeVisitor, C context) { | ||
return nodeVisitor.visitLambdaFunction(this, context); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format( | ||
"(%s) -> %s", | ||
funcArgs.stream().map(Object::toString).collect(Collectors.joining(", ")), | ||
function.toString()); | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
do you miss
ARRAY_LENGHT
? https://github.com/opensearch-project/opensearch-spark/blob/main/docs/ppl-lang/functions/ppl-collection.md#arrayThere 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.
Already add it.