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 02:34:58 GMT

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

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_r94642429
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/SqlConverter.java
---
    @@ -447,4 +458,50 @@ public RexNode ensureType(
           return node;
         }
       }
    +
    +  /**
    +   * Extension of {@link CalciteCatalogReader} to add ability to check for temporary
tables first
    +   * if schema is not indicated near table name during query parsing
    +   * or indicated workspace is default temporary workspace.
    +   */
    +  private class DrillCalciteCatalogReader extends CalciteCatalogReader {
    +
    +    private final String temporarySchema;
    +    private final UserSession session;
    +
    +    DrillCalciteCatalogReader(CalciteSchema rootSchema,
    +                                     boolean caseSensitive,
    +                                     List<String> defaultSchema,
    +                                     JavaTypeFactory typeFactory,
    +                                     String temporarySchema,
    +                                     UserSession session) {
    +      super(rootSchema, caseSensitive, defaultSchema, typeFactory);
    +      this.temporarySchema = temporarySchema;
    +      this.session = session;
    +    }
    +
    +    /**
    +     * If schema is not indicated (only one element in the list) or schema is default
temporary workspace,
    +     * we need to check among session temporary tables first in default temporary workspace.
    +     * If temporary table is found, its table instance will be returned,
    +     * otherwise search will be conducted in original workspace.
    +     *
    +     * @param names list of schema and table names, table name is always the last element
    +     * @return table instance, null otherwise
    +     */
    +    @Override
    +    public RelOptTableImpl getTable(final List<String> names) {
    +      RelOptTableImpl foundTemporaryTable = null;
    +      String schemaPath = SchemaUtilites.getSchemaPath(names.subList(0, names.size()
- 1));
    +      if (names.size() == 1 || schemaPath.equals(temporarySchema)) {
    +        String temporaryTable = session.findTemporaryTable(names.get(names.size() - 1));
    +        if (temporaryTable != null) {
    +          List<String> temporaryNames = Lists.newArrayList(temporarySchema);
    +          temporaryNames.add(temporaryTable);
    +          foundTemporaryTable = super.getTable(temporaryNames);
    +        }
    +      }
    +      return foundTemporaryTable == null ? super.getTable(names) : foundTemporaryTable;
    +    }
    --- End diff --
    
    A bit clearer:
    
    ```
          if (temporaryTable != null) {
            ...
            return super.getTable(name);
          }
          return super.getTable(names);
    ```
    
    Or
    
    ```
          if (temporaryTable != null) {
            names =
              Lists.newArrayList(temporarySchema, temporaryTable);
          }
          return super.getTable(names);
    ```


> 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