Github user vdiravka commented on a diff in the pull request:

    https://github.com/apache/drill/pull/541#discussion_r71585214
  
    --- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ViewHandler.java
 ---
    @@ -106,36 +106,43 @@ public PhysicalPlan getPlan(SqlNode sqlNode) throws 
ValidationException, RelConv
         }
       }
     
    -  /** Handler for Drop View DDL command. */
    -  public static class DropView extends ViewHandler {
    -    public DropView(SqlHandlerConfig config) {
    +  /** Handler for Drop View [If Exists] DDL command. */
    +  public static class DropViewIfExists extends ViewHandler {
    +    public DropViewIfExists(SqlHandlerConfig config) {
           super(config);
         }
     
         @Override
         public PhysicalPlan getPlan(SqlNode sqlNode) throws 
ValidationException, RelConversionException, IOException, ForemanSetupException 
{
    -      SqlDropView dropView = unwrap(sqlNode, SqlDropView.class);
    -      final String viewToDrop = dropView.getName();
    +      SqlDropViewIfExists dropView = unwrap(sqlNode, 
SqlDropViewIfExists.class);
    +      final String viewName = dropView.getName();
           final AbstractSchema drillSchema =
               
SchemaUtilites.resolveToMutableDrillSchema(context.getNewDefaultSchema(), 
dropView.getSchemaPath());
     
           final String schemaPath = drillSchema.getFullSchemaName();
     
    -      final Table existingTable = 
SqlHandlerUtil.getTableFromSchema(drillSchema, viewToDrop);
    -      if (existingTable != null && existingTable.getJdbcTableType() != 
Schema.TableType.VIEW) {
    -        throw UserException.validationError()
    -            .message("[%s] is not a VIEW in schema [%s]", viewToDrop, 
schemaPath)
    -            .build(logger);
    -      } else if (existingTable == null) {
    -        throw UserException.validationError()
    -            .message("Unknown view [%s] in schema [%s].", viewToDrop, 
schemaPath)
    -            .build(logger);
    +      final Table viewToDrop = 
SqlHandlerUtil.getTableFromSchema(drillSchema, viewName);
    +      if (dropView.checkViewExistence()) {
    +        if (viewToDrop == null || viewToDrop.getJdbcTableType() != 
Schema.TableType.VIEW){
    --- End diff --
    
    Answered above.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to