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

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_r95580468
  
    --- 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)) {
    --- End diff --
    
    Temporary tables names will be case-insensitive. This logic will be covered 
in `UserSession` class. Before storing / looking for / removing original temp 
table name will be converted to lower case.


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

Reply via email to