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

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


The following commit(s) were added to refs/heads/master by this push:
     new 0460d8a502 Adjust SQL "cannot plan" error message. (#12903)
0460d8a502 is described below

commit 0460d8a502fa5a1c5e06ef542fc9edf3aeb65e77
Author: Gian Merlino <[email protected]>
AuthorDate: Mon Aug 29 06:03:00 2022 -0700

    Adjust SQL "cannot plan" error message. (#12903)
    
    Two changes:
    
    1) Restore the text of the SQL query. It was removed in #12897, but
       then it was later pointed out that the text is helpful for end
       users querying Druid through tools that do not show the SQL queries
       that they are making.
    
    2) Adjust wording slightly, from "Cannot build plan for query" to
       "Query not supported". This will be clearer to most users. Generally
       the reason we get these errors is due to unsupported SQL constructs.
---
 .../java/org/apache/druid/sql/calcite/planner/DruidPlanner.java     | 6 +++---
 .../java/org/apache/druid/sql/calcite/BaseCalciteQueryTest.java     | 2 +-
 sql/src/test/java/org/apache/druid/sql/http/SqlResourceTest.java    | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git 
a/sql/src/main/java/org/apache/druid/sql/calcite/planner/DruidPlanner.java 
b/sql/src/main/java/org/apache/druid/sql/calcite/planner/DruidPlanner.java
index 430bf24a35..07f2a9dcb0 100644
--- a/sql/src/main/java/org/apache/druid/sql/calcite/planner/DruidPlanner.java
+++ b/sql/src/main/java/org/apache/druid/sql/calcite/planner/DruidPlanner.java
@@ -836,13 +836,13 @@ public class DruidPlanner implements Closeable
       errorMessage = exception.getMessage();
     }
     if (null == errorMessage) {
-      errorMessage = "Please check Broker logs for more details.";
+      errorMessage = "Please check Broker logs for additional details.";
     } else {
-      // Re-phrase since planning errors are more like hints
+      // Planning errors are more like hints: it isn't guaranteed that the 
planning error is actually what went wrong.
       errorMessage = "Possible error: " + errorMessage;
     }
     // Finally, add the query itself to error message that user will get.
-    return StringUtils.format("Cannot build plan for query. %s", errorMessage);
+    return StringUtils.format("Query not supported. %s SQL was: %s", 
errorMessage, plannerContext.getSql());
   }
 
   private static Set<RelOptTable> getBindableTables(final RelNode relNode)
diff --git 
a/sql/src/test/java/org/apache/druid/sql/calcite/BaseCalciteQueryTest.java 
b/sql/src/test/java/org/apache/druid/sql/calcite/BaseCalciteQueryTest.java
index cbe8660182..aea6a094d3 100644
--- a/sql/src/test/java/org/apache/druid/sql/calcite/BaseCalciteQueryTest.java
+++ b/sql/src/test/java/org/apache/druid/sql/calcite/BaseCalciteQueryTest.java
@@ -602,7 +602,7 @@ public class BaseCalciteQueryTest extends CalciteTestBase
     }
     Assert.assertEquals(
         sql,
-        StringUtils.format("Cannot build plan for query. %s", expectedError),
+        StringUtils.format("Query not supported. %s SQL was: %s", 
expectedError, sql),
         e.getMessage()
     );
   }
diff --git a/sql/src/test/java/org/apache/druid/sql/http/SqlResourceTest.java 
b/sql/src/test/java/org/apache/druid/sql/http/SqlResourceTest.java
index 20fe6578cb..4a16c344c1 100644
--- a/sql/src/test/java/org/apache/druid/sql/http/SqlResourceTest.java
+++ b/sql/src/test/java/org/apache/druid/sql/http/SqlResourceTest.java
@@ -1263,7 +1263,7 @@ public class SqlResourceTest extends CalciteTestBase
     Assert.assertEquals(PlanningError.UNSUPPORTED_SQL_ERROR.getErrorClass(), 
exception.getErrorClass());
     Assert.assertTrue(
         exception.getMessage()
-                 .contains("Cannot build plan for query. " +
+                 .contains("Query not supported. " +
                            "Possible error: SQL query requires order by 
non-time column [dim1 ASC] that is not supported.")
     );
     checkSqlRequestLog(false);
@@ -1288,7 +1288,7 @@ public class SqlResourceTest extends CalciteTestBase
     Assert.assertEquals(PlanningError.UNSUPPORTED_SQL_ERROR.getErrorClass(), 
exception.getErrorClass());
     Assert.assertTrue(
         exception.getMessage()
-                 .contains("Cannot build plan for query. " +
+                 .contains("Query not supported. " +
                            "Possible error: Max aggregation is not supported 
for 'STRING' type")
     );
     checkSqlRequestLog(false);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to