-
Notifications
You must be signed in to change notification settings - Fork 33
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
Conversation
hi @dr-lilienthal |
@dr-lilienthal
|
75e8dd4
to
6c13c69
Compare
1d82270
to
1622e1e
Compare
...cala/org/opensearch/flint/spark/ppl/PPLLogicalPlanBetweenExpressionTranslatorTestSuite.scala
Outdated
Show resolved
Hide resolved
ac5b2a7
to
f0d7aab
Compare
@@ -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 |
There was a problem hiding this comment.
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?
.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ...
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add BETWEEN
to keywordsCanBeId
There was a problem hiding this comment.
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` |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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") { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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** |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this 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.
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: Jens Schmidt <[email protected]>
Signed-off-by: Jens Schmidt <[email protected]>
Signed-off-by: Jens Schmidt <[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]>
Signed-off-by: Hendrik Saly <[email protected]>
Head branch was pushed to by a user without write access
* 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]>
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.