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

Add position() string function to PPL #1147

Conversation

margarit-h
Copy link
Contributor

@margarit-h margarit-h commented Dec 7, 2022

  • Add position() string function to PPL

Signed-off-by: Margarit Hakobyan [email protected]

Description

Usage: The syntax POSITION(substr IN str) returns the position of the first occurrence of substring substr in string str. Returns 0 if substr is not in str. Returns NULL if any argument is NULL.

Argument type: STRING, STRING

Return type INTEGER:

(STRING IN STRING) -> INTEGER

Example::

os> source=people | eval `POSITION('world' IN 'helloworld')` = POSITION('world' IN 'helloworld'), `POSITION('invalid' IN 'helloworld')`= POSITION('invalid' IN 'helloworld')  | fields `POSITION('world' IN 'helloworld')`, `POSITION('invalid' IN 'helloworld')`
fetched rows / total rows = 1/1
+-------------------------------------+---------------------------------------+
| POSITION('world' IN 'helloworld')   | POSITION('invalid' IN 'helloworld')   |
|-------------------------------------+---------------------------------------|
| 6                                   | 0                                     |
+-------------------------------------+---------------------------------------+

Issues Resolved

#1106

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.

* Add position() string function to PPL

Signed-off-by: Margarit Hakobyan <[email protected]>
@codecov-commenter
Copy link

codecov-commenter commented Dec 7, 2022

Codecov Report

Merging #1147 (72b75aa) into 2.x (354e843) will decrease coverage by 2.49%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##                2.x    #1147      +/-   ##
============================================
- Coverage     98.31%   95.81%   -2.50%     
- Complexity     3485     3486       +1     
============================================
  Files           348      358      +10     
  Lines          8707     9369     +662     
  Branches        555      674     +119     
============================================
+ Hits           8560     8977     +417     
- Misses          142      334     +192     
- Partials          5       58      +53     
Flag Coverage Δ
query-workbench 62.76% <ø> (?)
sql-engine 98.31% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...pensearch/sql/ppl/parser/AstExpressionBuilder.java 100.00% <100.00%> (ø)
workbench/public/components/Header/Header.tsx 100.00% <0.00%> (ø)
workbench/public/application.tsx 0.00% <0.00%> (ø)
...ublic/components/QueryResults/QueryResultsBody.tsx 68.32% <0.00%> (ø)
...h/public/components/QueryLanguageSwitch/Switch.tsx 85.71% <0.00%> (ø)
workbench/public/components/Main/main.tsx 53.00% <0.00%> (ø)
...ch/public/components/QueryResults/QueryResults.tsx 61.60% <0.00%> (ø)
workbench/public/components/SQLPage/SQLPage.tsx 100.00% <0.00%> (ø)
workbench/public/components/app.tsx 0.00% <0.00%> (ø)
workbench/public/components/PPLPage/PPLPage.tsx 56.52% <0.00%> (ø)
... and 1 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Yury-Fridlyand
Yury-Fridlyand previously approved these changes Dec 7, 2022
ppl/src/main/antlr/OpenSearchPPLParser.g4 Outdated Show resolved Hide resolved
Signed-off-by: Margarit Hakobyan <[email protected]>
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!

@Yury-Fridlyand Yury-Fridlyand merged commit f530770 into opensearch-project:2.x Dec 7, 2022
@Yury-Fridlyand Yury-Fridlyand deleted the integ-add-position-function-to-ppl branch December 7, 2022 19:25
@dai-chen dai-chen added enhancement New feature or request PPL Piped processing language labels Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request PPL Piped processing language
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants