Skip to content

Commit 1a0dd07

Browse files
committed
Remove unused constructor, consolidate tests
Signed-off-by: Lorenzo Stella <stellalo@amazon.de>
1 parent fecd769 commit 1a0dd07

5 files changed

Lines changed: 60 additions & 100 deletions

File tree

api/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ dependencies {
1616
testImplementation group: 'junit', name: 'junit', version: '4.13.2'
1717
testImplementation group: 'org.hamcrest', name: 'hamcrest-library', version: "${hamcrest_version}"
1818
testImplementation group: 'org.mockito', name: 'mockito-core', version: "${mockito_version}"
19+
testImplementation group: 'org.mockito', name: 'mockito-junit-jupiter', version: "${mockito_version}"
1920
testImplementation group: 'org.apache.calcite', name: 'calcite-testkit', version: '1.41.0'
2021
}
2122

api/src/main/java/org/opensearch/sql/api/UnifiedQueryPlanner.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,6 @@ public UnifiedQueryPlanner(
7979
this.settings = settings;
8080
}
8181

82-
/**
83-
* Constructs a UnifiedQueryPlanner for a given query type and schema root.
84-
*
85-
* @param queryType the query language type (e.g., PPL)
86-
* @param rootSchema the root Calcite schema containing all catalogs and tables
87-
* @param defaultPath dot-separated path of schema to set as default schema
88-
*/
89-
public UnifiedQueryPlanner(QueryType queryType, SchemaPlus rootSchema, String defaultPath) {
90-
this(queryType, rootSchema, defaultPath, null);
91-
}
92-
9382
/**
9483
* Parses and analyzes a query string into a Calcite logical plan (RelNode). TODO: Generate
9584
* optimal physical plan to fully unify query execution and leverage Calcite's optimizer.

api/src/test/java/org/opensearch/sql/api/CustomSettingsTest.java

Lines changed: 0 additions & 89 deletions
This file was deleted.

api/src/test/java/org/opensearch/sql/api/UnifiedQueryPlannerTest.java

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,55 @@
77

88
import static org.junit.Assert.assertNotNull;
99
import static org.junit.Assert.assertThrows;
10+
import static org.mockito.Mockito.when;
1011

1112
import java.util.Map;
1213
import org.apache.calcite.rel.RelNode;
1314
import org.apache.calcite.schema.Schema;
1415
import org.apache.calcite.schema.impl.AbstractSchema;
1516
import org.junit.Test;
17+
import org.junit.runner.RunWith;
18+
import org.mockito.Mock;
19+
import org.mockito.junit.MockitoJUnitRunner;
1620
import org.opensearch.sql.common.antlr.SyntaxCheckException;
21+
import org.opensearch.sql.common.setting.Settings;
1722
import org.opensearch.sql.executor.QueryType;
1823

1924
public class UnifiedQueryPlannerTest extends UnifiedQueryTestBase {
25+
// @RunWith(MockitoJUnitRunner.class)
26+
// public class UnifiedQueryPlannerTest {
27+
28+
// /** Test schema consists of a test table with id and name columns */
29+
// private final AbstractSchema testSchema =
30+
// new AbstractSchema() {
31+
// @Override
32+
// protected Map<String, Table> getTableMap() {
33+
// return Map.of(
34+
// "index",
35+
// new AbstractTable() {
36+
// @Override
37+
// public RelDataType getRowType(RelDataTypeFactory typeFactory) {
38+
// return typeFactory.createStructType(
39+
// List.of(
40+
// typeFactory.createSqlType(SqlTypeName.INTEGER),
41+
// typeFactory.createSqlType(SqlTypeName.VARCHAR)),
42+
// List.of("id", "name"));
43+
// }
44+
// },
45+
// "index2",
46+
// new AbstractTable() {
47+
// @Override
48+
// public RelDataType getRowType(RelDataTypeFactory typeFactory) {
49+
// return typeFactory.createStructType(
50+
// List.of(
51+
// typeFactory.createSqlType(SqlTypeName.INTEGER),
52+
// typeFactory.createSqlType(SqlTypeName.FLOAT)),
53+
// List.of("id", "value"));
54+
// }
55+
// }
56+
// );
57+
// }
58+
// };
2059

2160
/** Test catalog consists of test schema above */
2261
private final AbstractSchema testDeepSchema =
@@ -27,6 +66,8 @@ protected Map<String, Schema> getSubSchemaMap() {
2766
}
2867
};
2968

69+
@Mock private Settings testSettings;
70+
3071
@Test
3172
public void testPPLQueryPlanning() {
3273
UnifiedQueryPlanner planner =
@@ -155,4 +196,21 @@ public void testPlanPropagatingSyntaxCheckException() {
155196

156197
planner.plan("source = employees | eval"); // Trigger syntax error from parser
157198
}
199+
200+
@Test
201+
public void testJoinQuery() {
202+
when(testSettings.getSettingValue(Settings.Key.CALCITE_SUPPORT_ALL_JOIN_TYPES))
203+
.thenReturn(true);
204+
205+
UnifiedQueryPlanner planner = UnifiedQueryPlanner.builder()
206+
.language(QueryType.PPL)
207+
.catalog("opensearch", testSchema)
208+
.defaultNamespace("opensearch")
209+
.settings(testSettings)
210+
.build();
211+
212+
planner.plan(
213+
"source = index | join on index.id = index2.id index2"
214+
);
215+
}
158216
}

api/src/test/java/org/opensearch/sql/api/UnifiedQueryTestBase.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.opensearch.sql.executor.QueryType;
1818

1919
/** Base class for unified query tests providing common test schema and utilities. */
20+
@RunWith(MockitoJUnitRunner.class)
2021
public abstract class UnifiedQueryTestBase {
2122

2223
/** Test schema containing sample tables for testing */

0 commit comments

Comments
 (0)