Skip to content

Conversation

@margarit-h
Copy link

@margarit-h margarit-h commented Nov 30, 2022

Signed-off-by: Margarit Hakobyan margarith@bitquilltech.com

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::

opensearchsql> source=location | 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 = 2/2
+-------------------------------------+---------------------------------------+
| POSITION('world' IN 'helloworld')   | POSITION('invalid' IN 'helloworld')   |
|-------------------------------------+---------------------------------------|
| 6                                   | 0                                     |
| 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.

@margarit-h margarit-h changed the title Add position function to PPL Add position() function to PPL Nov 30, 2022
@margarit-h margarit-h requested a review from a team November 30, 2022 20:48
@codecov
Copy link

codecov bot commented Nov 30, 2022

Codecov Report

Merging #179 (8227419) into integ-add-position-to-ppl (c276efc) will decrease coverage by 2.50%.
The diff coverage is 100.00%.

@@                       Coverage Diff                       @@
##             integ-add-position-to-ppl     #179      +/-   ##
===============================================================
- Coverage                        98.30%   95.79%   -2.51%     
- Complexity                        3473     3474       +1     
===============================================================
  Files                              348      358      +10     
  Lines                             8668     9330     +662     
  Branches                           549      668     +119     
===============================================================
+ Hits                              8521     8938     +417     
- Misses                             142      334     +192     
- Partials                             5       58      +53     
Flag Coverage Δ
query-workbench 62.76% <ø> (?)
sql-engine 98.30% <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%> (ø)
...ch/public/components/QueryResults/QueryResults.tsx 61.60% <0.00%> (ø)
workbench/public/components/Main/main.tsx 53.00% <0.00%> (ø)
...h/public/components/QueryLanguageSwitch/Switch.tsx 85.71% <0.00%> (ø)
workbench/public/components/SQLPage/SQLPage.tsx 100.00% <0.00%> (ø)
workbench/public/components/app.tsx 0.00% <0.00%> (ø)
workbench/public/utils/PanelWrapper.tsx 100.00% <0.00%> (ø)
...ublic/components/QueryResults/QueryResultsBody.tsx 68.32% <0.00%> (ø)
workbench/public/application.tsx 0.00% <0.00%> (ø)
... and 1 more

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

@margarit-h margarit-h force-pushed the dev-add-position-to-ppl branch from c934c5d to b1ba96f Compare November 30, 2022 21:31
@margarit-h margarit-h force-pushed the dev-add-position-to-ppl branch from 2898974 to 9a80d7d Compare December 2, 2022 19:06
@margarit-h margarit-h force-pushed the integ-add-position-to-ppl branch 2 times, most recently from fc1bccf to eee57aa Compare December 5, 2022 23:28
@margarit-h margarit-h force-pushed the dev-add-position-to-ppl branch from 9a80d7d to e63e4a3 Compare December 6, 2022 00:09
@margarit-h margarit-h force-pushed the integ-add-position-to-ppl branch from b0d0014 to c276efc Compare December 6, 2022 18:18
margarit-h and others added 7 commits December 6, 2022 10:19
Signed-off-by: Margarit Hakobyan <margarith@bitquilltech.com>
Rebased
Signed-off-by: Margarit Hakobyan <margarith@bitquilltech.com>
Signed-off-by: Margarit Hakobyan <margarith@bitquilltech.com>
Signed-off-by: Margarit Hakobyan <margarith@bitquilltech.com>
Signed-off-by: Margarit Hakobyan <margarith@bitquilltech.com>
Co-authored-by: Andrew Carbonetto <andrewc@bitquilltech.com>
Signed-off-by: Margarit Hakobyan <margarith@bitquilltech.com>
Signed-off-by: Margarit Hakobyan <margarith@bitquilltech.com>
@margarit-h margarit-h force-pushed the dev-add-position-to-ppl branch from 843ce1b to 8227419 Compare December 6, 2022 18:19

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.

Return type: INTEGER

@margarit-h margarit-h merged commit f1be1c0 into integ-add-position-to-ppl Dec 6, 2022
@margarit-h margarit-h deleted the dev-add-position-to-ppl branch December 7, 2022 02:39
andy-k-improving pushed a commit that referenced this pull request Nov 16, 2024
* Import h3 library (#154)

Made following changes to make it compatible:
1. Rename package from elasticsearch to opensearch.geospatial
2. Update License headers
3. Update build file
4. Update settings to include sub projects

* Use Transport Request (#164)

Remove usage of deprecated BaseNodeRequest

* Update http client package to resolve build failure (#168) (#171)

* Introduce H3 min resolution constant (#165)

H3 version 1 has 16 resolutions, numbered 0 through 15.
Introduced a constant to represent min value, similar
to max value.

* Add geohex aggregation (#160)

This aggregation will use uber's h3 to group coordinates into H3 cell.
Created new aggregation type geohex_grid. The precision will be between
0 and 15. This aggreation has default precision as 5,
similar to geohash and geotile.

Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>

* Add integration test (#176)

Included integration test for geohex_grid.

Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>
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.

6 participants