[Calcite Engine] Support In expression#3429
[Calcite Engine] Support In expression#3429LantaoJin merged 8 commits intoopensearch-project:feature/calcite-enginefrom
Conversation
Signed-off-by: Heng Qian <qianheng@amazon.com>
| } | ||
|
|
||
| @Override | ||
| public RexNode visitIn(In node, CalcitePlanContext context) { |
There was a problem hiding this comment.
Calcite will optimize In expression to equal comparison if there is only 1 element in value list. We don't need to do such optimization ourself here like v2.
There was a problem hiding this comment.
We don't need to do such optimization ourself here like v2.
Do u mean we push down IN to OpenSearch as terms query, so Calcite optimized is not needed?
| @Ignore("https://github.com/opensearch-project/sql/issues/3428") | ||
| @Override | ||
| public void testIsNotNullFunction() throws IOException {} | ||
| ; |
Signed-off-by: Heng Qian <qianheng@amazon.com>
|
|
||
| @Test | ||
| public void testInExpression() { | ||
| assertEquals("source=t | where a in (***)", anonymize("source=t | where a in (1, 2, 3) ")); |
There was a problem hiding this comment.
add a test for
where a not in (1, 2, 3)
There was a problem hiding this comment.
"not in" is not supported in our g4, which mean v2 engine don't support it either. Need to add that implementation for v2 engine as well.
| JSONObject result = | ||
| executeQuery( | ||
| String.format( | ||
| "source=%s | where firstname in ('Amber') | fields firstname", TEST_INDEX_ACCOUNT)); |
There was a problem hiding this comment.
need a test for
where age in (36, 36.0, '36')
Signed-off-by: Heng Qian <qianheng@amazon.com>
…ine' into feature/calcite-engine-in
…ine' into feature/calcite-engine-in # Conflicts: # ppl/src/main/antlr/OpenSearchPPLParser.g4 # ppl/src/main/java/org/opensearch/sql/ppl/utils/PPLQueryDataAnonymizer.java
Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: Heng Qian <qianheng@amazon.com>
| super.init(); | ||
| } | ||
|
|
||
| @Ignore("https://github.com/opensearch-project/sql/issues/3428") |
There was a problem hiding this comment.
#3428 is LIKE function, why releated to testIsNotNull?
There was a problem hiding this comment.
this test case contains a like function as well.
"source=%s | where isnotnull(age) and like(firstname, 'Ambe_') | fields firstname"
There was a problem hiding this comment.
WhereCommandIT is an existed ppl IT which is extended by CalciteWhereCommandIT
| } | ||
|
|
||
| @Override | ||
| public RexNode visitIn(In node, CalcitePlanContext context) { |
There was a problem hiding this comment.
We don't need to do such optimization ourself here like v2.
Do u mean we push down IN to OpenSearch as terms query, so Calcite optimized is not needed?
| @Override | ||
| protected String getIncompatibleTypeErrMsg() { | ||
| return "In expression types are incompatible: fields type BIGINT, values type [INTEGER," | ||
| + " INTEGER, CHAR(4)]"; |
There was a problem hiding this comment.
CHAR(4) is not a valid OpenSearch PPL datatype.
There was a problem hiding this comment.
- No, I mean v2 has optimization to transform
column in (a)tocolumn = awhen converting. Since calcite will do such optimization in its optimization phase, we just need to convert it to the former expression directly without too much consideration.
| public class CalciteWhereCommandIT extends WhereCommandIT { | ||
| @Override | ||
| public void init() throws IOException { | ||
| enableCalcite(); |
There was a problem hiding this comment.
should we disableCalcite also? otherwise it may impact other tests?
There was a problem hiding this comment.
We have exclude 'org/opensearch/sql/calcite/remote/**' in build.gradle, it won't really run in CI. The parent class WhereCommandIT is the suite for test cases without calcite enabled.
Signed-off-by: Heng Qian <qianheng@amazon.com>
29c7625
into
opensearch-project:feature/calcite-engine
* [Calcite Engine] Support In expression Signed-off-by: Heng Qian <qianheng@amazon.com> * Address comments Signed-off-by: Heng Qian <qianheng@amazon.com> * Support NOT IN Signed-off-by: Heng Qian <qianheng@amazon.com> * Address comments Signed-off-by: Heng Qian <qianheng@amazon.com> * Add more UT Signed-off-by: Heng Qian <qianheng@amazon.com> * Address comments Signed-off-by: Heng Qian <qianheng@amazon.com> --------- Signed-off-by: Heng Qian <qianheng@amazon.com> Signed-off-by: xinyual <xinyual@amazon.com>
Description
Support In expression, also add data anonymizer for it.
./gradlew :integ-test:integTest --tests '*Calcite*ITsucceed locally.../../../ppl/src/test/java/org/opensearch/sql/ppl/calcite/*UT succeed locally.Related Issues
Resolves #3420
Check List
--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.