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

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

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

    https://github.com/apache/drill/pull/736#discussion_r99388535
  
    --- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/SqlConverter.java
 ---
    @@ -527,5 +529,31 @@ public RelOptTableImpl getTable(final List<String> 
names) {
           }
           return super.getTable(names);
         }
    +
    +    /**
    +     * Check if passed table is temporary or not should be done if:
    +     * <li>schema is not indicated (only one element in the names 
list)<li/>
    +     * <li>current schema or indicated schema is default temporary 
workspace<li/>
    +     *
    +     * Examples (where dfs.tmp is default temporary workspace):
    +     * <li>select * from t<li/>
    +     * <li>select * from dfs.tmp.t<li/>
    +     * <li>use dfs; select * from tmp.t<li/>
    +     *
    +     * @param names             list of schema and table names, table name 
is always the last element
    +     * @param defaultSchemaPath current schema path set using USE command
    +     * @param drillConfig       drill config
    +     * @return true if check for temporary table should be done, false 
otherwise
    +     */
    +    private boolean checkForTemporaryTable(List<String> names, String 
defaultSchemaPath, DrillConfig drillConfig) {
    +      if (names.size() == 1) {
    +        return true;
    +      }
    --- End diff --
    
    A single name might be a temporary table, or it might not be. Hence the 
name suggestion above. Is the intent to simply apply a filter so that we 
separate out those that are not temporary tables from those that may or may not 
be?
    
    If we want a positive check that this is, in fact, a temp table, wouldn't 
we have to resolve the name against known temp tables rather than just infer 
based on path length?
    
    And, if we are just filtering out known non-temp tables, is that good 
enough for the use case? That is, can the case we are fixing handle the 
ambiguous "may or may not be temporary" case?


> CTTAS: unable to resolve temporary table if workspace is indicated without 
> schema
> ---------------------------------------------------------------------------------
>
>                 Key: DRILL-5238
>                 URL: https://issues.apache.org/jira/browse/DRILL-5238
>             Project: Apache Drill
>          Issue Type: Bug
>    Affects Versions: 1.10.0
>            Reporter: Arina Ielchiieva
>            Assignee: Arina Ielchiieva
>              Labels: ready-to-commit
>             Fix For: 1.10.0
>
>
> Drill is unable to resolve temporary table if default temporary workspace is 
> partially indicated (schema was set using USE command and only workspace name 
> is used in query).
> {noformat}
> 0: jdbc:drill:zk=local> use dfs;
> +-------+----------------------------------+
> |  ok   |             summary              |
> +-------+----------------------------------+
> | true  | Default schema changed to [dfs]  |
> +-------+----------------------------------+
> 1 row selected (0.156 seconds)
> 0: jdbc:drill:zk=local> create temporary table tmp.t as select 'A' from 
> (values(1));
> +-----------+----------------------------+
> | Fragment  | Number of records written  |
> +-----------+----------------------------+
> | 0_0       | 1                          |
> +-----------+----------------------------+
> 1 row selected (1.525 seconds)
> 0: jdbc:drill:zk=local> select * from tmp.t;
> Feb 02, 2017 11:24:09 AM 
> org.apache.calcite.sql.validate.SqlValidatorException <init>
> SEVERE: org.apache.calcite.sql.validate.SqlValidatorException: Table 'tmp.t' 
> not found
> Feb 02, 2017 11:24:09 AM org.apache.calcite.runtime.CalciteException <init>
> SEVERE: org.apache.calcite.runtime.CalciteContextException: From line 1, 
> column 15 to line 1, column 17: Table 'tmp.t' not found
> Error: VALIDATION ERROR: From line 1, column 15 to line 1, column 17: Table 
> 'tmp.t' not found
> SQL Query null
> [Error Id: 5266cb67-9d37-4a94-9a4e-28a4a2f94be5 on localhost:31010] 
> (state=,code=0)
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to