Github user paul-rogers commented on a diff in the pull request:

    https://github.com/apache/drill/pull/666#discussion_r90697087
  
    --- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/DropTableHandler.java
 ---
    @@ -55,35 +57,48 @@ public DropTableHandler(SqlHandlerConfig config) {
        */
       @Override
       public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, 
RelConversionException, IOException {
    -
         SqlDropTable dropTableNode = ((SqlDropTable) sqlNode);
    -    SqlIdentifier tableIdentifier = dropTableNode.getTableIdentifier();
    -
    +    String originalTableName = dropTableNode.getName();
         SchemaPlus defaultSchema = config.getConverter().getDefaultSchema();
    -    AbstractSchema drillSchema = null;
    +    List<String> tableSchema = dropTableNode.getSchema();
     
    -    if (tableIdentifier != null) {
    -      drillSchema = 
SchemaUtilites.resolveToMutableDrillSchema(defaultSchema, 
dropTableNode.getSchema());
    -    }
    -
    -    String tableName = dropTableNode.getName();
    -    if (drillSchema == null) {
    -      throw UserException.validationError()
    -          .message("Invalid table_name [%s]", tableName)
    -          .build(logger);
    -    }
    +    boolean removedTemporaryTable = removeTemporaryTable(tableSchema, 
originalTableName);
    +    if (!removedTemporaryTable) {
    +      AbstractSchema drillSchema = 
SchemaUtilites.resolveToMutableDrillSchema(defaultSchema, tableSchema);
    +      if (drillSchema == null) {
    +        throw UserException.validationError().message("Invalid table_name 
[%s]", originalTableName).build(logger);
    +      }
     
    -    if (dropTableNode.checkTableExistence()) {
    -      final Table tableToDrop = 
SqlHandlerUtil.getTableFromSchema(drillSchema, tableName);
    +      final Table tableToDrop = 
SqlHandlerUtil.getTableFromSchema(drillSchema, originalTableName);
           if (tableToDrop == null || tableToDrop.getJdbcTableType() != 
Schema.TableType.TABLE) {
    -        return DirectPlan.createDirectPlan(context, true,
    -            String.format("Table [%s] not found", tableName));
    +        if (dropTableNode.checkTableExistence()) {
    --- End diff --
    
    I wonder about this a bit... This is the planner, is it not? We're checking 
if the table exists. But, the actual drop table will occur later (below?) Is 
this a race condition? Should we just skip checking table existence here if we 
just do it again when doing the actual delete?


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