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 #184

Conversation

margarit-h
Copy link

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

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

[List any issues this PR will resolve]

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: Margarit Hakobyan <[email protected]>
Signed-off-by: Margarit Hakobyan <[email protected]>
@margarit-h margarit-h requested a review from a team December 6, 2022 23:45
@codecov
Copy link

codecov bot commented Dec 6, 2022

Codecov Report

Merging #184 (48ac268) into integ-add-position-function-to-ppl (354e843) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@                          Coverage Diff                          @@
##             integ-add-position-function-to-ppl     #184   +/-   ##
=====================================================================
  Coverage                                 98.31%   98.31%           
- Complexity                                 3485     3486    +1     
=====================================================================
  Files                                       348      348           
  Lines                                      8707     8711    +4     
  Branches                                    555      555           
=====================================================================
+ Hits                                       8560     8564    +4     
  Misses                                      142      142           
  Partials                                      5        5           
Flag Coverage Δ
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%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more


Argument type: STRING, STRING

Return type INTEGER:

Choose a reason for hiding this comment

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

Suggested change
Return type INTEGER:
Return type: INTEGER

assertEquals(2, result.getInt("total"));
verifyDataRows(result, rows("eight"), rows("eleven"));
}
}

Choose a reason for hiding this comment

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

Need ending newline.

assertEquals(2, result.getInt("total"));
verifyDataRows(result, rows("eight"), rows("eleven"));
}
}

Choose a reason for hiding this comment

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

It really would would like a new line here.

Signed-off-by: Margarit Hakobyan <[email protected]>
Signed-off-by: Margarit Hakobyan <[email protected]>
@margarit-h margarit-h merged commit 72b75aa into integ-add-position-function-to-ppl Dec 7, 2022
@margarit-h margarit-h deleted the dev-add-position-function-to-ppl branch December 7, 2022 02:39
Yury-Fridlyand pushed a commit that referenced this pull request Dec 8, 2022
* Add position() string function to PPL (#184)

Signed-off-by: Margarit Hakobyan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants