You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2021/11/24 03:28:27 UTC

[GitHub] [druid] jihoonson commented on a change in pull request #11911: Human-readable and actionable SQL error messages

jihoonson commented on a change in pull request #11911:
URL: https://github.com/apache/druid/pull/11911#discussion_r755579773



##########
File path: sql/src/main/java/org/apache/druid/sql/calcite/planner/UnsupportedQueryFeatureException.java
##########
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.sql.calcite.planner;
+
+import org.apache.calcite.plan.RelOptPlanner;
+import org.apache.druid.java.util.common.StringUtils;
+
+/**
+ * This class is different from {@link org.apache.calcite.plan.RelOptPlanner.CannotPlanException} in that the error
+ * messages are user-friendly unlike it's parent class. This exception class be used instead of

Review comment:
       ```suggestion
    * messages are user-friendly unlike its parent class. This exception class should be used instead of
   ```

##########
File path: sql/src/main/java/org/apache/druid/sql/calcite/planner/DruidPlanner.java
##########
@@ -185,14 +187,29 @@ public PlannerResult plan(final String sql) throws SqlParseException, Validation
     try {
       return planWithDruidConvention(explain, root);
     }
-    catch (RelOptPlanner.CannotPlanException e) {
+    catch (Exception e) {
+      Throwable cannotPlanException = Throwables.getCauseOfType(e, RelOptPlanner.CannotPlanException.class);
+      if (null == cannotPlanException) {
+        // Not a CannotPlanningException, rethrow without trying with bindable
+        throw e;
+      }
       // Try again with BINDABLE convention. Used for querying Values and metadata tables.
       try {
         return planWithBindableConvention(explain, root);
       }
       catch (Exception e2) {
         e.addSuppressed(e2);
-        throw e;
+        log.noStackTrace().warn(e, "Failed to plan the query '%s'", sql);

Review comment:
       Should it omit stack trace only when `QueryContexts.isDebug() = true`?

##########
File path: sql/src/main/java/org/apache/druid/sql/calcite/planner/UnsupportedQueryFeatureException.java
##########
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.sql.calcite.planner;
+
+import org.apache.calcite.plan.RelOptPlanner;
+import org.apache.druid.java.util.common.StringUtils;
+
+/**
+ * This class is different from {@link org.apache.calcite.plan.RelOptPlanner.CannotPlanException} in that the error
+ * messages are user-friendly unlike it's parent class. This exception class be used instead of
+ * {@link org.apache.druid.java.util.common.ISE} or {@link org.apache.druid.java.util.common.IAE} when processing is
+ * to be halted during planning. Similarly, Druid planner can catch these exception and know that the error

Review comment:
       ```suggestion
    * to be halted during planning. Similarly, Druid planner can catch this exception and know that the error
   ```

##########
File path: sql/src/main/java/org/apache/druid/sql/calcite/planner/UnsupportedQueryFeatureException.java
##########
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.sql.calcite.planner;
+
+import org.apache.calcite.plan.RelOptPlanner;
+import org.apache.druid.java.util.common.StringUtils;
+
+/**
+ * This class is different from {@link org.apache.calcite.plan.RelOptPlanner.CannotPlanException} in that the error
+ * messages are user-friendly unlike it's parent class. This exception class be used instead of
+ * {@link org.apache.druid.java.util.common.ISE} or {@link org.apache.druid.java.util.common.IAE} when processing is
+ * to be halted during planning. Similarly, Druid planner can catch these exception and know that the error
+ * can be directly exposed to end-user.

Review comment:
       ```suggestion
    * can be directly exposed to end-users.
   ```




-- 
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-unsubscribe@druid.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org