77
88import static org .junit .Assert .assertNotNull ;
99import static org .junit .Assert .assertThrows ;
10+ import static org .mockito .Mockito .when ;
1011
1112import java .util .Map ;
1213import org .apache .calcite .rel .RelNode ;
1314import org .apache .calcite .schema .Schema ;
1415import org .apache .calcite .schema .impl .AbstractSchema ;
1516import org .junit .Test ;
17+ import org .junit .runner .RunWith ;
18+ import org .mockito .Mock ;
19+ import org .mockito .junit .MockitoJUnitRunner ;
1620import org .opensearch .sql .common .antlr .SyntaxCheckException ;
21+ import org .opensearch .sql .common .setting .Settings ;
1722import org .opensearch .sql .executor .QueryType ;
1823
1924public 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}
0 commit comments