Support CASE function with Calcite#3558
Merged
penghuo merged 6 commits intoopensearch-project:mainfrom Apr 24, 2025
Merged
Conversation
Signed-off-by: Lantao Jin <ltjin@amazon.com>
Signed-off-by: Lantao Jin <ltjin@amazon.com>
dai-chen
previously approved these changes
Apr 17, 2025
ppl/src/main/java/org/opensearch/sql/ppl/parser/AstExpressionBuilder.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Lantao Jin <ltjin@amazon.com>
7 tasks
qianheng-aws
previously approved these changes
Apr 21, 2025
Collaborator
Member
Author
Do you know the reason to make documentation executable? It's hard to debug if doctest fails. @penghuo |
Collaborator
doctest has grown to have three primary uses, more reading opendistro-for-elasticsearch/sql#497
|
Signed-off-by: Lantao Jin <ltjin@amazon.com>
penghuo
reviewed
Apr 23, 2025
| os> source=accounts | eval result = case(age > 35, firstname, age < 30, lastname else employer) | fields result, firstname, lastname | ||
| fetched rows / total rows = 4/4 | ||
| +--------+-----------+----------+ | ||
| | result | firstname | lastname | |
Collaborator
There was a problem hiding this comment.
add age and employer, fields result, age, firstname, lastname, employer
| | null | Dale | Adams | | ||
| +--------+-----------+----------+ | ||
|
|
||
| os> source=accounts | eval result = case(age > 35, firstname, age < 30, lastname) | fields result, firstname, lastname |
Signed-off-by: Lantao Jin <ltjin@amazon.com>
qianheng-aws
approved these changes
Apr 24, 2025
penghuo
approved these changes
Apr 24, 2025
Member
Author
|
I will backport this to branch 3.0 since it should be treated as bug:
Can you approve it? @penghuo @anasalkouz @model-collapse |
|
Approved to backport |
opensearch-trigger-bot bot
pushed a commit
that referenced
this pull request
Apr 25, 2025
* Support CASE function with Calcite Signed-off-by: Lantao Jin <ltjin@amazon.com> * add anonymizer Signed-off-by: Lantao Jin <ltjin@amazon.com> * address comment and fix varchar literal bug Signed-off-by: Lantao Jin <ltjin@amazon.com> * add doc Signed-off-by: Lantao Jin <ltjin@amazon.com> * fix doctest Signed-off-by: Lantao Jin <ltjin@amazon.com> * fix doctest Signed-off-by: Lantao Jin <ltjin@amazon.com> --------- Signed-off-by: Lantao Jin <ltjin@amazon.com> (cherry picked from commit 47e6a2a) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
penghuo
pushed a commit
that referenced
this pull request
Apr 25, 2025
* Support CASE function with Calcite * add anonymizer * address comment and fix varchar literal bug * add doc * fix doctest * fix doctest --------- (cherry picked from commit 47e6a2a) Signed-off-by: Lantao Jin <ltjin@amazon.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
penghuo
pushed a commit
that referenced
this pull request
Jun 16, 2025
* Support CASE function with Calcite Signed-off-by: Lantao Jin <ltjin@amazon.com> * add anonymizer Signed-off-by: Lantao Jin <ltjin@amazon.com> * address comment and fix varchar literal bug Signed-off-by: Lantao Jin <ltjin@amazon.com> * add doc Signed-off-by: Lantao Jin <ltjin@amazon.com> * fix doctest Signed-off-by: Lantao Jin <ltjin@amazon.com> * fix doctest Signed-off-by: Lantao Jin <ltjin@amazon.com> --------- Signed-off-by: Lantao Jin <ltjin@amazon.com> Signed-off-by: xinyual <xinyual@amazon.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Support CASE function with Calcite (v3) and v2 engine.
Its syntax should be support in PPL OpenSearch as well.
https://github.com/opensearch-project/opensearch-spark/blob/6832737577119221819c49235c212020c0214fed/ppl-spark-integration/src/main/antlr4/OpenSearchPPLParser.g4#L489-L491
Fix the bug of string literal: enforce to CHAR(1) type or VARCHAR type to avoid CHAR(n)
Related Issues
Resolves #3536
Check List
--signoff.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.