Support function coalesce with Calcite#3628
Merged
LantaoJin merged 3 commits intoopensearch-project:mainfrom May 21, 2025
Merged
Support function coalesce with Calcite#3628LantaoJin merged 3 commits intoopensearch-project:mainfrom
coalesce with Calcite#3628LantaoJin merged 3 commits intoopensearch-project:mainfrom
Conversation
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
coalesce with Calcite
LantaoJin
reviewed
May 19, 2025
| JSONObject actual = | ||
| executeQuery( | ||
| String.format( | ||
| "source=%s | where age = 10 | eval new_country = coalesce(name, state, country) | fields name, state, country, new_country", |
Member
There was a problem hiding this comment.
could you add a case if the values of name, state, country are all null
Collaborator
Author
There was a problem hiding this comment.
I added a cased of coalesce(name, state, name) = null to avoid injecting another row. Does this suffice?
|
|
||
| Example:: | ||
|
|
||
| os> source=accounts | eval result = coalesce(employer, firstname, lastname) | fields result, firstname, lastname, employer |
Member
There was a problem hiding this comment.
Change the os> to PPL to disable it in current doctest since this is only working with Calcite enabled.
|
|
||
| Usage: coalesce(field1, field2, ...) return the first non-null value in the argument list. | ||
|
|
||
| Argument type: all the supported data type, (NOTE : if parameters have different type, you will fail semantic check) |
Member
There was a problem hiding this comment.
(NOTE : if parameters have different type, you will fail semantic check)
Change to the The data types of all fields must be same.
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
dai-chen
reviewed
May 19, 2025
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
dai-chen
approved these changes
May 20, 2025
LantaoJin
approved these changes
May 21, 2025
Member
|
Is this merged to 3.1? |
Collaborator
Author
Yes! |
penghuo
pushed a commit
that referenced
this pull request
Jun 16, 2025
* Support function coalesce with Calcite Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> * Add antoher test case for coalesce & disable coalesce's doctest Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> --------- Signed-off-by: Yuanchun Shen <yuanchu@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 functions coalesce with Calcite, which returns the first non-null value in its parameter list.
Issues Resolved
Resolves #3610
Check List
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.