2121import org .opensearch .cluster .service .ClusterService ;
2222import org .opensearch .common .settings .Settings ;
2323import org .opensearch .index .IndexSettings ;
24+ import org .opensearch .indices .IndicesService ;
2425import org .opensearch .sql .executor .QueryType ;
2526import org .opensearch .transport .client .node .NodeClient ;
2627
@@ -142,7 +143,7 @@ public void nullAndEmptyQueriesRouteToLucene() {
142143 }
143144
144145 @ Test
145- public void showStatementRoutesToLucene () {
146+ public void showStatementNotRoutedToAnalyticsEngine () {
146147 registerIndex (
147148 "parquet_logs" ,
148149 Settings .builder ()
@@ -154,7 +155,7 @@ public void showStatementRoutesToLucene() {
154155 }
155156
156157 @ Test
157- public void describeStatementRoutesToLucene () {
158+ public void describeStatementNotRoutedToAnalyticsEngine () {
158159 registerIndex (
159160 "parquet_logs" ,
160161 Settings .builder ()
@@ -165,6 +166,59 @@ public void describeStatementRoutesToLucene() {
165166 assertFalse (action .isAnalyticsIndex ("DESCRIBE TABLES LIKE 'parquet_logs'" , QueryType .SQL ));
166167 }
167168
169+ @ Test
170+ public void showStatementNotRoutedToAnalyticsEngineUnderClusterComposite () {
171+ enableClusterComposite ();
172+ assertFalse (action .isAnalyticsIndex ("SHOW TABLES LIKE 'parquet_logs'" , QueryType .SQL ));
173+ }
174+
175+ @ Test
176+ public void describeStatementNotRoutedToAnalyticsEngineUnderClusterComposite () {
177+ enableClusterComposite ();
178+ assertFalse (action .isAnalyticsIndex ("DESCRIBE TABLES LIKE 'parquet_logs'" , QueryType .SQL ));
179+ }
180+
181+ @ Test
182+ public void dataQueryStillRoutesToAnalyticsUnderClusterComposite () {
183+ enableClusterComposite ();
184+ assertTrue (action .isAnalyticsIndex ("SELECT * FROM parquet_logs" , QueryType .SQL ));
185+ }
186+
187+ @ Test
188+ public void unparseableQueryRoutesToAnalyticsUnderClusterComposite () {
189+ enableClusterComposite ();
190+ // malformed -> AE re-parses & reports
191+ assertTrue (action .isAnalyticsIndex ("SELECT FROM WHERE" , QueryType .SQL ));
192+ }
193+
194+ @ Test
195+ public void pplDescribeNotRoutedToAnalyticsEngineUnderClusterComposite () {
196+ enableClusterComposite ();
197+ assertFalse (action .isAnalyticsIndex ("describe parquet_logs" , QueryType .PPL ));
198+ }
199+
200+ @ Test
201+ public void pplDataQueryStillRoutesToAnalyticsUnderClusterComposite () {
202+ enableClusterComposite ();
203+ assertTrue (action .isAnalyticsIndex ("source = parquet_logs | fields ts" , QueryType .PPL ));
204+ }
205+
206+ @ Test
207+ public void pplUnparseableQueryRoutesToAnalyticsUnderClusterComposite () {
208+ enableClusterComposite ();
209+ // malformed -> AE re-parses & reports
210+ assertTrue (action .isAnalyticsIndex ("source = parquet_logs | | fields ts" , QueryType .PPL ));
211+ }
212+
213+ private void enableClusterComposite () {
214+ when (clusterService .getSettings ())
215+ .thenReturn (
216+ Settings .builder ()
217+ .put (
218+ IndicesService .CLUSTER_PLUGGABLE_DATAFORMAT_VALUE_SETTING .getKey (), "composite" )
219+ .build ());
220+ }
221+
168222 private void registerIndex (String name , Settings settings ) {
169223 IndexMetadata indexMetadata = mock (IndexMetadata .class );
170224 when (indexMetadata .getSettings ()).thenReturn (settings );
0 commit comments