File tree Expand file tree Collapse file tree
main/java/org/opensearch/sql/api
test/java/org/opensearch/sql/api Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2727import org .opensearch .sql .calcite .CalciteRelNodeVisitor ;
2828import org .opensearch .sql .common .antlr .SyntaxCheckException ;
2929import org .opensearch .sql .common .error .ErrorReport ;
30+ import org .opensearch .sql .exception .CalciteUnsupportedException ;
3031import org .opensearch .sql .exception .QueryEngineException ;
3132import org .opensearch .sql .exception .SemanticCheckException ;
3233
@@ -73,6 +74,10 @@ public RelNode plan(String query) {
7374 }
7475 return plan ;
7576 });
77+ } catch (CalciteUnsupportedException e ) {
78+ // Unsupported feature (e.g. table functions) is an invalid query, i.e. a client error.
79+ // Must precede the QueryEngineException branch as it is a subclass.
80+ throw new SemanticCheckException (e .getMessage (), e );
7681 } catch (SyntaxCheckException
7782 | QueryEngineException
7883 | UnsupportedOperationException
Original file line number Diff line number Diff line change 1616import org .junit .Test ;
1717import org .opensearch .sql .common .antlr .SyntaxCheckException ;
1818import org .opensearch .sql .common .error .ErrorReport ;
19+ import org .opensearch .sql .exception .CalciteUnsupportedException ;
1920import org .opensearch .sql .exception .SemanticCheckException ;
2021import org .opensearch .sql .executor .QueryType ;
2122
@@ -147,6 +148,17 @@ public void invalidTableIsRethrownAsSemanticCheckException() {
147148 .assertCauseType (CalciteException .class );
148149 }
149150
151+ @ Test
152+ public void unsupportedFeatureIsRethrownAsSemanticCheckException () {
153+ // A feature unsupported on the analytics engine (here a PPL command that raises
154+ // CalciteUnsupportedException; SQL table functions like vectorSearch() take the same path) is
155+ // an invalid query, normalized to a SemanticCheckException so callers classify it as a 4xx.
156+ givenInvalidQuery ("source = catalog.employees | kmeans" )
157+ .assertErrorType (SemanticCheckException .class )
158+ .assertCauseType (CalciteUnsupportedException .class )
159+ .assertErrorMessageContains ("unsupported in Calcite" );
160+ }
161+
150162 @ Test
151163 public void assertionErrorIsWrappedAsSemanticCheckException () {
152164 // Remove when the underlying Calcite assertion is fixed.
You can’t perform that action at this time.
0 commit comments