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 Thu, 05 Jan 2017 21:52:58 GMT

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

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

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

    https://github.com/apache/drill/pull/666#discussion_r94857634
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserSession.java
---
    @@ -207,18 +245,85 @@ public SchemaPlus getDefaultSchema(SchemaPlus rootSchema) {
           return null;
         }
     
    -    final SchemaPlus defaultSchema = SchemaUtilites.findSchema(rootSchema, defaultSchemaPath);
    +    return SchemaUtilites.findSchema(rootSchema, defaultSchemaPath);
    +  }
     
    -    if (defaultSchema == null) {
    -      // If the current schema resolves to null, return root schema as the current default
schema.
    -      return defaultSchema;
    +  public boolean setSessionOption(String name, String value) {
    +    return true;
    +  }
    +
    +  /**
    +   * @return unique session identifier
    +   */
    +  public String getSessionId() { return sessionId; }
    +
    +  /**
    +   * Creates and adds session temporary location if absent using schema configuration.
    +   * Generates temporary table name and stores it's original name as key
    +   * and generated name as value in  session temporary tables cache.
    +   * If original table name already exists, new name is not regenerated and is reused.
    +   * This can happen if default temporary workspace was changed (file system or location)
or
    +   * orphan temporary table name has remained (name was registered but table creation
did not succeed).
    +   *
    +   * @param schema table schema
    +   * @param tableName original table name
    +   * @return generated temporary table name
    +   * @throws IOException if error during session temporary location creation
    +   */
    +  public String registerTemporaryTable(AbstractSchema schema, String tableName) throws
IOException {
    +    if (schema instanceof WorkspaceSchemaFactory.WorkspaceSchema) {
    +      addTemporaryLocation((WorkspaceSchemaFactory.WorkspaceSchema) schema);
    +      String temporaryTableName = Paths.get(sessionId, UUID.randomUUID().toString()).toString();
    +      String oldTemporaryTableName = temporaryTables.putIfAbsent(tableName, temporaryTableName);
    +      return oldTemporaryTableName == null ? temporaryTableName : oldTemporaryTableName;
    +    } else {
    +      throw new DrillRuntimeException("Temporary workspace must be instance of WorkspaceSchemaFactory.WorkspaceSchema");
         }
    +  }
     
    -    return defaultSchema;
    +  /**
    +   * Returns generated temporary table name from the list of session temporary tables,
null otherwise.
    +   *
    +   * @param tableName original table name
    +   * @return generated temporary table name
    +   */
    +  public String findTemporaryTable(String tableName) {
    +    return temporaryTables.get(tableName);
       }
     
    -  public boolean setSessionOption(String name, String value) {
    -    return true;
    +  /**
    +   * Removes temporary table name from the list of session temporary tables.
    +   *
    +   * @param tableName original table name
    +   */
    +  public void removeTemporaryTable(String tableName) {
    --- End diff --
    
    This method is public and sure looks like what should be called to remove a table. But,
removing a temp table should delete it from disk since, once it is removed from the table,
we know longer know about it, right? Should the work done in the DROP TABLE command shift
here so we have a single place that does the deregister-table-and-delete-file as a single
operation in a single place?


> 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