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 PPL Between functionality #758

Merged
merged 15 commits into from
Oct 29, 2024
Merged

Conversation

dr-lilienthal
Copy link
Contributor

Description

Add PPL Between functionality

Issues Resolved

#679

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.

@YANG-DB
Copy link
Member

YANG-DB commented Oct 9, 2024

hi @dr-lilienthal
plz fix DCO ...

@YANG-DB YANG-DB added Lang:PPL Pipe Processing Language support 0.5 0.6 and removed 0.5 labels Oct 9, 2024
@YANG-DB
Copy link
Member

YANG-DB commented Oct 11, 2024

@dr-lilienthal
please add documentation in the following locations:

  • ../docs/ppl-lang/PPL-Example-Commands.md
  • ../docs/ppl-lang/README.md
    Thanks

@salyh salyh force-pushed the between branch 3 times, most recently from 75e8dd4 to 6c13c69 Compare October 16, 2024 05:14
@dr-lilienthal dr-lilienthal marked this pull request as ready for review October 16, 2024 06:56
@dr-lilienthal dr-lilienthal force-pushed the between branch 2 times, most recently from 1d82270 to 1622e1e Compare October 17, 2024 18:25
@dr-lilienthal
Copy link
Contributor Author

@YANG-DB ready for review CC: @salyh

@dr-lilienthal dr-lilienthal requested a review from YANG-DB October 18, 2024 09:18
@salyh salyh force-pushed the between branch 2 times, most recently from ac5b2a7 to f0d7aab Compare October 25, 2024 08:49
@salyh salyh requested a review from ykmr1224 as a code owner October 25, 2024 08:49
@@ -371,6 +371,7 @@ logicalExpression
| left = logicalExpression OR right = logicalExpression # logicalOr
| left = logicalExpression XOR right = logicalExpression # logicalXor
| booleanExpression # booleanExpr
| expr1 = functionArg NOT? BETWEEN expr2 = functionArg AND expr3 = functionArg # between
Copy link
Member

@LantaoJin LantaoJin Oct 25, 2024

Choose a reason for hiding this comment

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

Move this new expression into booleanExpression comparisonExpression, then delete NOT?.

Copy link
Contributor

Choose a reason for hiding this comment

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

I changed this but the syntax also changes from

where a not between x and y -> where not a between x and y Is this desired?

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I see. We can keep the NOT? here, and better to add two tests for a not between and not a between. They should have the same logic evaluation.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, just like IN, a not in is ANSI SQL, but not a in is the original design in OpenSearch SQL. So yes, keep the NOT? symbol here.

Copy link
Contributor

@salyh salyh Oct 28, 2024

Choose a reason for hiding this comment

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

Would be great if can discuss such things in the beginning of the PR next time ...

Copy link
Contributor

Choose a reason for hiding this comment

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

done, both "nots" are now supported and are tested

@@ -368,6 +368,7 @@ LIKE: 'LIKE';
ISNULL: 'ISNULL';
ISNOTNULL: 'ISNOTNULL';
ISPRESENT: 'ISPRESENT';
BETWEEN: 'BETWEEN';
Copy link
Member

Choose a reason for hiding this comment

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

Add BETWEEN to keywordsCanBeId

Copy link
Contributor

Choose a reason for hiding this comment

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

done

@@ -49,6 +49,8 @@ _- **Limitation: new field added by eval command with a function cannot be dropp
- `source = table | where isempty(a)`
- `source = table | where isblank(a)`
- `source = table | where case(length(a) > 6, 'True' else 'False') = 'True'`
- `source = table | where a between 1 and 4`
Copy link
Member

Choose a reason for hiding this comment

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

I think we need explain the range of between is [1, 4] rather than (1, 4) in user doc. From the code implementation, I think it is [1, 4]. In anther word, when a = 1, the predicate returns True

Copy link
Contributor

Choose a reason for hiding this comment

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

done

})
}

test("test between should return records NOT between two values") {
Copy link
Member

Choose a reason for hiding this comment

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

Can you add two tests (between and not between) with Date/Time in condition?
I think you can use the table by createTimeSeriesTable

Copy link
Member

@LantaoJin LantaoJin Oct 28, 2024

Choose a reason for hiding this comment

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

Please add another test where age between 20 + 1 and 30 - 1. There is similar query in TPCH q6: l_discount between .06 - 0.01 and .06 + 0.01

Copy link
Contributor

Choose a reason for hiding this comment

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

done

@@ -55,6 +55,8 @@ _- **Limitation: new field added by eval command with a function cannot be dropp
- `source = table | where isempty(a)`
- `source = table | where isblank(a)`
- `source = table | where case(length(a) > 6, 'True' else 'False') = 'True'`
- `source = table | where a between 1 and 4` - Note: This returns a >= 1 and a <= 4, i.e. [1, 4]
Copy link
Member

Choose a reason for hiding this comment

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

@dr-lilienthal please also copy these comments to the ppl-between.md

Copy link
Contributor

Choose a reason for hiding this comment

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

done

- `... | where a between 1 and 4`
- `... | where b not between '2024-09-10' and '2025-09-10'`

2. **Proposed impl**
Copy link
Member

Choose a reason for hiding this comment

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

you can remove the proposed impl here since there was no actual discussion about how it should be implemented...

Copy link
Contributor

Choose a reason for hiding this comment

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

done

Copy link
Member

@LantaoJin LantaoJin left a comment

Choose a reason for hiding this comment

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

LGTM. Enabled auto-merge when CI passed.

@LantaoJin LantaoJin enabled auto-merge (squash) October 29, 2024 00:47
salyh and others added 15 commits October 29, 2024 10:01
Signed-off-by: Hendrik Saly <[email protected]>
Signed-off-by: Hendrik Saly <[email protected]>
Signed-off-by: Jens Schmidt <[email protected]>
Signed-off-by: Hendrik Saly <[email protected]>
Signed-off-by: Hendrik Saly <[email protected]>
Signed-off-by: Hendrik Saly <[email protected]>
Signed-off-by: Hendrik Saly <[email protected]>
Signed-off-by: Hendrik Saly <[email protected]>
Signed-off-by: Hendrik Saly <[email protected]>
auto-merge was automatically disabled October 29, 2024 09:04

Head branch was pushed to by a user without write access

@YANG-DB YANG-DB self-requested a review October 29, 2024 16:46
@YANG-DB YANG-DB merged commit 82770ec into opensearch-project:main Oct 29, 2024
4 checks passed
kenrickyap pushed a commit to Bit-Quill/opensearch-spark that referenced this pull request Dec 11, 2024
* Implement between

Signed-off-by: Hendrik Saly <[email protected]>

* add integration test for between command to the straight and NOT usage

Signed-off-by: Jens Schmidt <[email protected]>

* Add docs

Signed-off-by: Hendrik Saly <[email protected]>

* Add proposed syntax to ppl planning

Signed-off-by: Hendrik Saly <[email protected]>

* adjust gitignore

Signed-off-by: Jens Schmidt <[email protected]>

* adjust gitignore: add spark-bin

Signed-off-by: Jens Schmidt <[email protected]>

* clean .gitignore: remove local adjustments

Signed-off-by: Jens Schmidt <[email protected]>

* update integration test to use between keyword

Signed-off-by: Jens Schmidt <[email protected]>

* Move to comparisonExpression

Signed-off-by: Hendrik Saly <[email protected]>

* Added to keywordsCanBeId

Signed-off-by: Hendrik Saly <[email protected]>

* Update docs

Signed-off-by: Hendrik Saly <[email protected]>

* Add additional tests

Signed-off-by: Hendrik Saly <[email protected]>

* Move to comparisonExpression -2-

Signed-off-by: Hendrik Saly <[email protected]>

* Fix docs

Signed-off-by: Hendrik Saly <[email protected]>

* Added IT tests

Signed-off-by: Hendrik Saly <[email protected]>

---------

Signed-off-by: Hendrik Saly <[email protected]>
Signed-off-by: Jens Schmidt <[email protected]>
Co-authored-by: Hendrik Saly <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.6 Lang:PPL Pipe Processing Language support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants