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()));
}
}