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

Support complex predicates for IF function in PPL #2756

Merged
merged 3 commits into from
Jul 24, 2024

Conversation

LantaoJin
Copy link
Member

@LantaoJin LantaoJin commented Jun 15, 2024

Description

The predicate of function if(predicate, arg1, arg2) in PPL should support complex expression.
The current implementation only supports TrueLiteral and FalseLiteral, just like the example given in doc. Query such as |eval test=if(pgs > 2, "yes", "no") will fail with "details": "Failed to parse query due to offending symbol [>] at:

This PR aims to support complex predicate expression, following cases will be supported:

  • if(a > 2, arg1, arg2)
  • if(a != 2, arg1, arg2)
  • if(isnull(a), arg1, arg2)
  • if(not a>2, arg1, arg2)
  • if(not a in (0, 1), arg1, arg2)"
  • if(not a in (0, 1) OR isnull(a), arg1, arg2)
  • if(like(a, 'a%b%c_d'), arg1, arg2)
  • and more

Issues Resolved

Resolves #2600 and #2653

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --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.

Signed-off-by: Lantao Jin <ltjin@amazon.com>
penghuo
penghuo previously approved these changes Jun 19, 2024
Copy link
Collaborator

@penghuo penghuo left a comment

Choose a reason for hiding this comment

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

Thx!

dai-chen
dai-chen previously approved these changes Jun 24, 2024
Copy link
Collaborator

@dai-chen dai-chen left a comment

Choose a reason for hiding this comment

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

Thanks for the changes!

vamsi-amazon
vamsi-amazon previously approved these changes Jun 24, 2024
@LantaoJin
Copy link
Member Author

None of current build issues caused by this PR.

@penghuo
Copy link
Collaborator

penghuo commented Jul 15, 2024

could u merge latest change from main and re-run test.

@LantaoJin
Copy link
Member Author

Gently ping @penghuo @vamsi-amazon @YANG-DB

Copy link
Collaborator

@penghuo penghuo left a comment

Choose a reason for hiding this comment

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

Thx!

@penghuo penghuo merged commit 593ffab into opensearch-project:main Jul 24, 2024
14 checks passed
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/sql/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/sql/backport-2.x
# Create a new branch
git switch --create backport/backport-2756-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 593ffabbbdc6d6a9529ef3d6c233785e29fedb07
# Push it to GitHub
git push --set-upstream origin backport/backport-2756-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/sql/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-2756-to-2.x.

manasvinibs pushed a commit to manasvinibs/sql that referenced this pull request Aug 14, 2024
jzonthemtn pushed a commit to jzonthemtn/sql that referenced this pull request Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Conditional statement not supported using Opensearch PPL
4 participants