Examples of SqlDropView


Examples of org.apache.drill.exec.planner.sql.parser.SqlDropView

      super(null, context);
    }

    @Override
    public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException {
      SqlDropView dropView = unwrap(sqlNode, SqlDropView.class);

      try {
        SchemaPlus schema = findSchema(context.getRootSchema(), context.getNewDefaultSchema(), dropView.getSchemaPath());
        AbstractSchema drillSchema = getDrillSchema(schema);

        String schemaPath = drillSchema.getFullSchemaName();
        if (!drillSchema.isMutable())
          return DirectPlan.createDirectPlan(context, false, String.format("Schema '%s' is not a mutable schema. " +
              "Views don't exist in this schema", schemaPath));

        if (drillSchema instanceof WorkspaceSchema) {
          ((WorkspaceSchema) drillSchema).dropView(dropView.getName());;
        }else{
          return DirectPlan.createDirectPlan(context, false, "Schema provided was not a workspace schema.");
        }

        return DirectPlan.createDirectPlan(context, true,
            String.format("View '%s' deleted successfully from '%s' schema", dropView.getName(), schemaPath));
      } catch(Exception e) {
        logger.debug("Failed to delete view {}", dropView.getName(), e);
        return DirectPlan.createDirectPlan(context, false, String.format("Error: %s", e.getMessage()));
      }
    }
View Full Code Here

Examples of org.apache.drill.exec.planner.sql.parser.SqlDropView

      super(null, context);
    }

    @Override
    public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException {
      SqlDropView dropView = unwrap(sqlNode, SqlDropView.class);

      try {
        SchemaPlus schema = findSchema(context.getRootSchema(), context.getNewDefaultSchema(), dropView.getSchemaPath());
        AbstractSchema drillSchema = getDrillSchema(schema);

        String schemaPath = drillSchema.getFullSchemaName();
        if (!drillSchema.isMutable()) {
          return DirectPlan.createDirectPlan(context, false, String.format("Schema '%s' is not a mutable schema. " +
              "Views don't exist in this schema", schemaPath));
        }

        if (drillSchema instanceof WorkspaceSchema) {
          ((WorkspaceSchema) drillSchema).dropView(dropView.getName());;
        } else {
          return DirectPlan.createDirectPlan(context, false, "Schema provided was not a workspace schema.");
        }

        return DirectPlan.createDirectPlan(context, true,
            String.format("View '%s' deleted successfully from '%s' schema", dropView.getName(), schemaPath));
      } catch(Exception e) {
        logger.debug("Failed to delete view {}", dropView.getName(), e);
        return DirectPlan.createDirectPlan(context, false, String.format("Error: %s", e.getMessage()));
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.