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:41 GMT
Github user arina-ielchiieva commented on a diff in the pull request:

    https://github.com/apache/drill/pull/666#discussion_r94760042
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/CreateTableHandler.java
---
    @@ -242,4 +267,53 @@ private RexNode composeDisjunction(final RexBuilder rexBuilder, List<RexNode>
co
         return node;
       }
     
    +  /**
    +   * Gets schema path defined in create table statement.
    +   * If temporary table is being created and schema is not indicated,
    +   * uses default temporary workspace.
    +   *
    +   * @param sqlCreateTable create table call
    +   * @param temporaryWorkspace default temporary workspace
    +   * @return table schema path
    +   */
    +  private List<String> getSchemaPath(SqlCreateTable sqlCreateTable, String temporaryWorkspace)
{
    +    List<String> indicatedSchemaPath = sqlCreateTable.getSchemaPath();
    +    if (sqlCreateTable.isTemporary() && indicatedSchemaPath.size() == 0) {
    +      indicatedSchemaPath = Lists.newArrayList(temporaryWorkspace);
    +    }
    +    return indicatedSchemaPath;
    +  }
    +
    +  /**
    +   * Checks if any object (persistent table / temporary table / view)
    +   * with the same name as table to be created exists in indicated schema.
    +   *
    +   * @param drillSchema schema where table will be created
    +   * @param tableName table name
    +   * @param isTemporaryWorkspace is default temporary workspace
    +   * @param userSession current user session
    +   * @throws UserException if duplicate is found
    +   */
    +  private void checkDuplicatedObjectExistence(AbstractSchema drillSchema,
    +                                              String tableName,
    +                                              boolean isTemporaryWorkspace,
    +                                              UserSession userSession) {
    +    String schemaPath = drillSchema.getFullSchemaName();
    +    boolean isTemporaryTable = false;
    +    if (isTemporaryWorkspace) {
    +      String temporaryTableName = userSession.findTemporaryTable(tableName);
    +      if (temporaryTableName != null) {
    +        Table temporaryTable = SqlHandlerUtil.getTableFromSchema(drillSchema, temporaryTableName);
    --- End diff --
    
    We register table name before query starts but we don't have to worry about concurrency
here. Even if temp table queries pass planning stage, one of them will fail during execution
stage (when writing files on disk). Writer fails immediately if finds out that file it tries
to create already exists.


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