drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arina-ielchiieva <...@git.apache.org>
Subject [GitHub] drill pull request #666: DRILL-4956: Temporary tables support
Date Tue, 17 Jan 2017 15:30:42 GMT
Github user arina-ielchiieva commented on a diff in the pull request:

    https://github.com/apache/drill/pull/666#discussion_r94760594
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/DropTableHandler.java
---
    @@ -55,35 +58,79 @@ 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();
    +
    +    boolean removedTemporaryTable = removeTemporaryTable(defaultSchema, tableSchema,
originalTableName);
    +    // if table to be dropped is not temporary table, we need to check among persistent
tables or views
    +    if (!removedTemporaryTable) {
    +      AbstractSchema drillSchema = SchemaUtilites.resolveToMutableDrillSchema(defaultSchema,
tableSchema);
    +      Table tableToDrop = SqlHandlerUtil.getTableFromSchema(drillSchema, originalTableName);
    +      if (tableToDrop == null || tableToDrop.getJdbcTableType() != Schema.TableType.TABLE)
{
    +        if (dropTableNode.checkTableExistence()) {
    --- End diff --
    
    `checkTableExistence()` is indication for `IF EXISTS` clause in drop command statement.
    Ex: `drop table dfs.tmp.foo` vs `drop table if exists dfs.tmp.foo`
    If `IF EXISTS` clause is present, drop command will return result saying 'Table not found'
to the user if table to be dropped doesn't exist, otherwise error is thrown.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message