gortiz commented on code in PR #13554:
URL: https://github.com/apache/pinot/pull/13554#discussion_r1668197364


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotQueryResource.java:
##########
@@ -275,22 +276,17 @@ private String getQueryResponse(String query, @Nullable 
SqlNode sqlNode, String
       tableName = 
_pinotHelixResourceManager.getActualTableName(inputTableName, database);
     } catch (Exception e) {
       LOGGER.error("Caught exception while compiling query: {}", query, e);
-      try {
-        // try to compile the query using multi-stage engine and suggest using 
it if it succeeds.
-        LOGGER.info("Trying to compile query {} using multi-stage engine", 
query);
-        QueryEnvironment queryEnvironment = new QueryEnvironment(new 
TypeFactory(new TypeSystem()),
-            CalciteSchemaBuilder.asRootSchema(new PinotCatalog(database, 
_pinotHelixResourceManager.getTableCache()),
-                database), null, null);
-        queryEnvironment.getTableNamesForQuery(query);
-        LOGGER.info("Successfully compiled query using multi-stage engine: 
{}", query);
+
+      // Check if the query is a v2 supported query
+      if (ParserUtils.canCompileQueryUsingV2Engine(query, 
CalciteSchemaBuilder.asRootSchema(
+          new PinotCatalog(database, 
_pinotHelixResourceManager.getTableCache()), database))) {
         return QueryException.getException(QueryException.SQL_PARSING_ERROR, 
new Exception(
-            "It seems that the query is only supported by the multi-stage 
engine, please try it by checking the "
-                + "\"Use Multi-Stage Engine\" box above")).toString();
-      } catch (Exception multipleTablesPassingException) {
-        LOGGER.error("Caught exception while compiling query using multi-stage 
engine: {}",
-            query, multipleTablesPassingException);
+            "It seems that the query is only supported by the multi-stage 
query engine, please retry the query using "
+                + "the multi-stage query engine "
+                + 
"(https://docs.pinot.apache.org/developers/advanced/v2-multi-stage-query-engine)")).toString();
+      } else {
+        return QueryException.getException(QueryException.SQL_PARSING_ERROR, 
e).toString();
       }

Review Comment:
   Couldn't we just use the message that comes from the broker?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to