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 more PPL builtin functions by adding a name mapping #504

Merged
merged 2 commits into from
Aug 2, 2024

Conversation

LantaoJin
Copy link
Member

@LantaoJin LantaoJin commented Aug 1, 2024

Description

Followup of #448.
Some PPL builtin functions could not be translated to Spark builtin functions correctly due to they have different function names (signatures). This PR supports more PPL builtin functions by adding a name mapping. With this PR, following functions could be supported to translate to Spark builtin functions correctly:

+
-
*
/
%
DAY_OF_WEEK
DAY_OF_MONTH
DAY_OF_YEAR
WEEK_OF_YEAR
WEEK
MONTH_OF_YEAR
HOUR_OF_DAY
MINUTE_OF_HOUR
SECOND_OF_MINUTE
SUBDATE
ADDDATE
DATEDIFF
LOCALTIME
IS_NULL
IS_NOT_NULL

Issues Resolved

Resolves #502

Check List

  • Updated documentation (ppl-spark-integration/README.md)
  • Implemented unit tests
  • Implemented tests for combination with other commands
  • 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.

@LantaoJin LantaoJin marked this pull request as ready for review August 1, 2024 17:00
Copy link
Member

@YANG-DB YANG-DB left a comment

Choose a reason for hiding this comment

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

very nice refactor with the PlanTest.comparePlans(...) !

*/
static final Map<String, String> SPARK_BUILTIN_FUNCTION_NAME_MAPPING = new ImmutableMap.Builder<String, String>()
// arithmetic operators
.put(BuiltinFunctionName.ADD.name().toLowerCase(Locale.ROOT), "+")
Copy link
Member

Choose a reason for hiding this comment

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

plz add static import for BuiltinFunctionName.* (shortens the map declaration)

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@dai-chen dai-chen added bug Something isn't working 0.5 labels Aug 2, 2024
@YANG-DB YANG-DB merged commit d3e54d4 into opensearch-project:main Aug 2, 2024
6 checks passed
@YANG-DB YANG-DB added Lang:PPL Pipe Processing Language support backport 0.5 labels Aug 14, 2024
@opensearch-trigger-bot
Copy link

The backport to 0.5 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/opensearch-spark/backport-0.5 0.5
# Navigate to the new working tree
pushd ../.worktrees/opensearch-spark/backport-0.5
# Create a new branch
git switch --create backport/backport-504-to-0.5
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 d3e54d48c578680ccaa38ddc96a74372bf64eb84
# Push it to GitHub
git push --set-upstream origin backport/backport-504-to-0.5
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/opensearch-spark/backport-0.5

Then, create a pull request where the base branch is 0.5 and the compare/head branch is backport/backport-504-to-0.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.5 backport 0.5 bug Something isn't working Lang:PPL Pipe Processing Language support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Need a function name mapping to support more builtin function translations
3 participants