devozerov commented on a change in pull request #2371:
URL: https://github.com/apache/calcite/pull/2371#discussion_r593860042



##########
File path: server/src/main/java/org/apache/calcite/server/ServerDdlExecutor.java
##########
@@ -281,41 +281,54 @@ public void execute(SqlCreateFunction create,
    * {@code DROP VIEW} commands. */
   public void execute(SqlDropObject drop,
       CalcitePrepare.Context context) {
-    final List<String> path = context.getDefaultSchemaPath();
-    CalciteSchema schema = context.getRootSchema();
-    for (String p : path) {
-      schema = schema.getSubSchema(p, true);
-    }
-    final boolean existed;
+    final Pair<CalciteSchema, String> pair = schema(context, false, drop.name);
+    CalciteSchema schema = pair.left;
+    String objectName = pair.right;
+    assert objectName != null;
+
+    boolean existed;
     switch (drop.getKind()) {
     case DROP_TABLE:
     case DROP_MATERIALIZED_VIEW:
-      existed = schema.removeTable(drop.name.getSimple());
-      if (!existed && !drop.ifExists) {
+      Table materializedView = schema != null && drop.getKind() == 
SqlKind.DROP_MATERIALIZED_VIEW
+          ? schema.plus().getTable(objectName) : null;
+
+      existed = schema != null && schema.removeTable(objectName);
+      if (existed) {
+        if (materializedView != null) {

Review comment:
       Fixed, one of the `if` statements was redundant. Are there any 
guidelines on the maximum number of nested `if`-s?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to