drill-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DRILL-4956) Temporary tables support
Date Tue, 17 Jan 2017 15:31:27 GMT

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

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

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.


> Temporary tables support
> ------------------------
>
>                 Key: DRILL-4956
>                 URL: https://issues.apache.org/jira/browse/DRILL-4956
>             Project: Apache Drill
>          Issue Type: Improvement
>    Affects Versions: 1.8.0
>            Reporter: Arina Ielchiieva
>            Assignee: Arina Ielchiieva
>              Labels: doc-impacting
>             Fix For: Future
>
>
> Link to design doc - https://docs.google.com/document/d/1gSRo_w6q2WR5fPx7SsQ5IaVmJXJ6xCOJfYGyqpVOC-g/edit



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

Mime
View raw message