Skip to content

Commit 9aaff7a

Browse files
authored
Add explain ITs with Calcite without pushdown (opensearch-project#3786)
* Add explain ITs with Calcite wihtout pushdown Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> * Test explain sort with Calcite without push-down Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> * Complete explain tests for no-pushdown cases Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> * Test explain search without pushdown Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> --------- Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
1 parent a3cd42e commit 9aaff7a

41 files changed

Lines changed: 269 additions & 161 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

integ-test/src/test/java/org/opensearch/sql/calcite/pushdown/CalciteNoPushdownIT.java renamed to integ-test/src/test/java/org/opensearch/sql/calcite/CalciteNoPushdownIT.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
package org.opensearch.sql.calcite.pushdown;
6+
package org.opensearch.sql.calcite;
77

88
import org.junit.AfterClass;
99
import org.junit.BeforeClass;
@@ -30,8 +30,7 @@
3030
CalciteDedupCommandIT.class,
3131
CalciteDescribeCommandIT.class,
3232
CalciteExpandCommandIT.class,
33-
// TODO: Add expected plans for CalciteExplainIT without pushdown
34-
// CalciteExplainIT.class,
33+
CalciteExplainIT.class,
3534
CalciteFieldsCommandIT.class,
3635
CalciteFillNullCommandIT.class,
3736
CalciteFlattenCommandIT.class,

integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalciteExplainIT.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ public void supportSearchSargPushDown_singleRange() throws IOException {
3030
String query =
3131
"source=opensearch-sql_test_index_account | where age >= 1.0 and age < 10 | fields age";
3232
var result = explainQueryToString(query);
33-
String expected =
34-
loadFromFile("expectedOutput/calcite/explain_sarg_filter_push_single_range.json");
33+
String expected = loadExpectedPlan("explain_sarg_filter_push_single_range.json");
3534
assertJsonEqualsIgnoreId(expected, result);
3635
}
3736

@@ -42,16 +41,14 @@ public void supportSearchSargPushDown_multiRange() throws IOException {
4241
"source=opensearch-sql_test_index_account | where (age > 20 and age < 28) or (age > 25 and"
4342
+ " age < 30) or (age >= 1 and age <= 10) or age = 0 | fields age";
4443
var result = explainQueryToString(query);
45-
String expected =
46-
loadFromFile("expectedOutput/calcite/explain_sarg_filter_push_multi_range.json");
44+
String expected = loadExpectedPlan("explain_sarg_filter_push_multi_range.json");
4745
assertJsonEqualsIgnoreId(expected, result);
4846
}
4947

5048
// Only for Calcite
5149
@Test
5250
public void supportSearchSargPushDown_timeRange() throws IOException {
53-
String expected =
54-
loadFromFile("expectedOutput/calcite/explain_sarg_filter_push_time_range.json");
51+
String expected = loadExpectedPlan("explain_sarg_filter_push_time_range.json");
5552
assertJsonEqualsIgnoreId(
5653
expected,
5754
explainQueryToString(

integ-test/src/test/java/org/opensearch/sql/ppl/ExplainIT.java

Lines changed: 57 additions & 143 deletions
Large diffs are not rendered by default.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"calcite": {
3+
"logical": "LogicalProject(age=[COALESCE($8, -1)], balance=[COALESCE($3, -1)])\n CalciteLogicalIndexScan(table=[[OpenSearch, opensearch-sql_test_index_account]])\n",
4+
"physical": "EnumerableCalc(expr#0..16=[{inputs}], expr#17=[-1], expr#18=[COALESCE($t8, $t17)], expr#19=[COALESCE($t3, $t17)], age=[$t18], balance=[$t19])\n CalciteEnumerableIndexScan(table=[[OpenSearch, opensearch-sql_test_index_account]])\n"
5+
}
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"calcite": {
3+
"logical": "LogicalProject(avg_age=[$2], state=[$0], city=[$1])\n LogicalAggregate(group=[{0, 1}], avg_age=[AVG($2)])\n LogicalProject(state=[$7], city=[$5], age=[$8])\n LogicalFilter(condition=[>($8, 30)])\n CalciteLogicalIndexScan(table=[[OpenSearch, opensearch-sql_test_index_account]])\n",
4+
"physical": "EnumerableCalc(expr#0..3=[{inputs}], expr#4=[0], expr#5=[=($t3, $t4)], expr#6=[null:BIGINT], expr#7=[CASE($t5, $t6, $t2)], expr#8=[CAST($t7):DOUBLE], expr#9=[/($t8, $t3)], avg_age=[$t9], state=[$t1], city=[$t0])\n EnumerableAggregate(group=[{5, 7}], agg#0=[$SUM0($8)], agg#1=[COUNT($8)])\n EnumerableCalc(expr#0..16=[{inputs}], expr#17=[30], expr#18=[>($t8, $t17)], proj#0..16=[{exprs}], $condition=[$t18])\n CalciteEnumerableIndexScan(table=[[OpenSearch, opensearch-sql_test_index_account]])\n"
5+
}
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"calcite": {
3+
"logical": "LogicalProject(age=[$8])\n LogicalFilter(condition=[>($3, 10000)])\n LogicalFilter(condition=[<($8, 40)])\n LogicalFilter(condition=[>($8, 30)])\n CalciteLogicalIndexScan(table=[[OpenSearch, opensearch-sql_test_index_account]])\n",
4+
"physical": "EnumerableCalc(expr#0..16=[{inputs}], expr#17=[Sarg[(30..40)]], expr#18=[SEARCH($t8, $t17)], expr#19=[10000], expr#20=[>($t3, $t19)], expr#21=[AND($t18, $t20)], age=[$t8], $condition=[$t21])\n CalciteEnumerableIndexScan(table=[[OpenSearch, opensearch-sql_test_index_account]])\n"
5+
}
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"calcite": {
3+
"logical": "LogicalFilter(condition=[<($0, DATE('2018-11-09 00:00:00.000000000':VARCHAR))])\n LogicalFilter(condition=[>($0, DATE('2016-12-08 00:00:00.123456789':VARCHAR))])\n LogicalProject(yyyy-MM-dd=[$83])\n CalciteLogicalIndexScan(table=[[OpenSearch, opensearch-sql_test_index_date_formats]])\n",
4+
"physical": "EnumerableCalc(expr#0..94=[{inputs}], expr#95=[Sarg[('2016-12-08':VARCHAR..'2018-11-09':VARCHAR)]:VARCHAR], expr#96=[SEARCH($t83, $t95)], yyyy-MM-dd=[$t83], $condition=[$t96])\n CalciteEnumerableIndexScan(table=[[OpenSearch, opensearch-sql_test_index_date_formats]])\n"
5+
}
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"calcite": {
3+
"logical": "LogicalFilter(condition=[<($0, TIME('2018-11-09 19:00:00.123456789':VARCHAR))])\n LogicalFilter(condition=[>($0, TIME('2016-12-08 12:00:00.123456789':VARCHAR))])\n LogicalProject(custom_time=[$49])\n CalciteLogicalIndexScan(table=[[OpenSearch, opensearch-sql_test_index_date_formats]])\n",
4+
"physical": "EnumerableCalc(expr#0..94=[{inputs}], expr#95=[Sarg[('12:00:00.123456789':VARCHAR..'19:00:00.123456789':VARCHAR)]:VARCHAR], expr#96=[SEARCH($t49, $t95)], custom_time=[$t49], $condition=[$t96])\n CalciteEnumerableIndexScan(table=[[OpenSearch, opensearch-sql_test_index_date_formats]])\n"
5+
}
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"calcite": {
3+
"logical": "LogicalProject(account_number=[$0], firstname=[$1], address=[$2], birthdate=[$3], gender=[$4], city=[$5], lastname=[$6], balance=[$7], employer=[$8], state=[$9], age=[$10], email=[$11], male=[$12])\n LogicalFilter(condition=[<($3, TIMESTAMP('2018-11-09 00:00:00.000000000':VARCHAR))])\n LogicalFilter(condition=[>($3, TIMESTAMP('2016-12-08 00:00:00.000000000':VARCHAR))])\n CalciteLogicalIndexScan(table=[[OpenSearch, opensearch-sql_test_index_bank]])\n",
4+
"physical": "EnumerableCalc(expr#0..18=[{inputs}], expr#19=[Sarg[('2016-12-08 00:00:00':VARCHAR..'2018-11-09 00:00:00':VARCHAR)]:VARCHAR], expr#20=[SEARCH($t3, $t19)], proj#0..12=[{exprs}], $condition=[$t20])\n CalciteEnumerableIndexScan(table=[[OpenSearch, opensearch-sql_test_index_bank]])\n"
5+
}
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"calcite": {
3+
"logical": "LogicalProject(age=[$8])\n LogicalSort(fetch=[5])\n LogicalFilter(condition=[>($8, 30)])\n CalciteLogicalIndexScan(table=[[OpenSearch, opensearch-sql_test_index_account]])\n",
4+
"physical": "EnumerableCalc(expr#0..16=[{inputs}], age=[$t8])\n EnumerableLimit(fetch=[5])\n EnumerableCalc(expr#0..16=[{inputs}], expr#17=[30], expr#18=[>($t8, $t17)], proj#0..16=[{exprs}], $condition=[$t18])\n CalciteEnumerableIndexScan(table=[[OpenSearch, opensearch-sql_test_index_account]])\n"
5+
}
6+
}

0 commit comments

Comments
 (0)