[ 
https://issues.apache.org/jira/browse/DRILL-4673?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15388612#comment-15388612
 ] 

ASF GitHub Bot commented on DRILL-4673:
---------------------------------------

Github user sudheeshkatkam commented on the issue:

    https://github.com/apache/drill/pull/541
  
    tl;dr +1, please open a ticket.
    
    Moving conversation. Vitalii said:
    > I checked every schema#getTable and found that every method can throw 
exception only if something go wrong (permissionError, dataReadError, 
IOException etc). 
    getTableFromSchema()can not throw any exception, because in this method 
catch (Exception e) is used.
    
    Correct, `catch(Exception e)` is used, but the exception is wrapped in a 
`DrillRuntimeException` and re-thrown.
    
    I think it "happens so" that all plugins are doing the right thing. To 
explain myself, there are two cases that I am concerned about:
    
    1.  `getTableFromSchema` (and underlying `schema#getTable`) throws an 
exception when a table does not exist. For example, if the HBase plugin 
supports dropping tables in the future, an invalid table name will cause the 
query to [fail 
with](https://github.com/apache/drill/blob/master/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/DrillHBaseTable.java#L42)
 a `TableNotFoundException`, which is exactly the case an exception should not 
thrown, if `IF EXISTS` exists.  _For now,_ since hbase schema is not mutable, 
the [check for schema 
mutability](https://github.com/apache/drill/pull/541/files#diff-50862f72c560b2d1bd9af36e83019d80R66),
 before deleting the table, fails.
    
    2. `getTableFromSchema` (and underlying `schema#getTable`) does not return 
`null` for non-existent tables, and `schema#dropTable` will fail. _For now_, 
only two schema support dropping tables: `WorkspaceSchema` and `KuduTables`, 
and they return `null` for non-existent tables. The check for schema mutability 
fails for other schema.
    
    Overall, it seems there is an unwritten rule (`schema#getTable` should 
return `null` if the table does not exist) that should be documented, and HBase 
plugin should be fixed. AFAIK other plugins follow this rule.
    
    +1 for the changes; I think we should track these above issues in another 
ticket.


> Implement "DROP TABLE IF EXISTS" for drill to prevent FAILED status on 
> command return
> -------------------------------------------------------------------------------------
>
>                 Key: DRILL-4673
>                 URL: https://issues.apache.org/jira/browse/DRILL-4673
>             Project: Apache Drill
>          Issue Type: New Feature
>          Components: Functions - Drill
>            Reporter: Vitalii Diravka
>            Assignee: Vitalii Diravka
>            Priority: Minor
>              Labels: drill
>
> Implement "DROP TABLE IF EXISTS" for drill to prevent FAILED status on 
> command "DROP TABLE" return if table doesn't exist.
> The same for "DROP VIEW IF EXISTS"



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to