This is an automated email from the ASF dual-hosted git repository.

xiangfu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 513f79df24 improve error message to suggest multi-stage engine when 
possible (#11451)
513f79df24 is described below

commit 513f79df24501ea75eb172278ffd0129ac791d94
Author: Haitao Zhang <hai...@startree.ai>
AuthorDate: Wed Aug 30 05:07:07 2023 -0700

    improve error message to suggest multi-stage engine when possible (#11451)
    
    * improve error message to suggest multi-stage engine when possible
    
    * update exception message
---
 .../controller/api/resources/PinotQueryResource.java      | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git 
a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotQueryResource.java
 
b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotQueryResource.java
index a913ca33ec..3c87e51e8c 100644
--- 
a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotQueryResource.java
+++ 
b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotQueryResource.java
@@ -239,6 +239,21 @@ public class PinotQueryResource {
       tableName = 
_pinotHelixResourceManager.getActualTableName(inputTableName);
     } 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(_pinotHelixResourceManager.getTableCache())), null,
+            null);
+        queryEnvironment.getTableNamesForQuery(query);
+        LOGGER.info("Successfully compiled query using multi-stage engine: 
{}", query);
+        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);
+      }
       return QueryException.getException(QueryException.SQL_PARSING_ERROR, 
e).toString();
     }
     String rawTableName = TableNameBuilder.extractRawTableName(tableName);


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

Reply via email to