You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hive.apache.org by "Zheng Shao (JIRA)" <ji...@apache.org> on 2009/05/01 08:55:30 UTC

[jira] Commented: (HIVE-466) Fix queries like "SELECT t.*, t.a"

    [ https://issues.apache.org/jira/browse/HIVE-466?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12704904#action_12704904 ] 

Zheng Shao commented on HIVE-466:
---------------------------------

Explain shows that the second SelectOperator are trying to access field 2, but there is only field 0 and field 1 from the first SelectOperator.
The reason is that when the first SelectOperator is analyzing "*", it adds one more to the columnId, so the columnId of the second "a" becomes 2 instead of 1.

{code}
hive> explain select * from (select *, a as a2 from zshao_lazy) z order by a2 limit 10;
ABSTRACT SYNTAX TREE:
  (TOK_QUERY (TOK_FROM (TOK_SUBQUERY (TOK_QUERY (TOK_FROM (TOK_TABREF zshao_lazy)) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR TOK_ALLCOLREF) (TOK_SELEXPR (TOK_COLREF a) a2)))) z)) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR TOK_ALLCOLREF)) (TOK_ORDERBY (TOK_COLREF a2)) (TOK_LIMIT 10)))

STAGE DEPENDENCIES:
  Stage-1 is a root stage
  Stage-0 is a root stage

STAGE PLANS:
  Stage: Stage-1
    Map Reduce
      Alias -> Map Operator Tree:
        z:zshao_lazy
            Select Operator
              expressions:
                    expr: a
                    type: int
                    expr: a
                    type: int
              Select Operator
                expressions:
                      expr: 0
                      type: int
                      expr: 2
                      type: int
                Reduce Output Operator
                  key expressions:
                        expr: 1
                        type: int
                  sort order: +
                  tag: -1
                  value expressions:
                        expr: 0
                        type: int
                        expr: 1
                        type: int
      Reduce Operator Tree:
        Extract
          Limit
            File Output Operator
              compressed: true
              GlobalTableId: 0
              table:
                  input format: org.apache.hadoop.mapred.TextInputFormat
                  output format: org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat

  Stage: Stage-0
    Fetch Operator
      limit: 10


Time taken: 8.681 seconds
{code}


> Fix queries like "SELECT t.*, t.a"
> ----------------------------------
>
>                 Key: HIVE-466
>                 URL: https://issues.apache.org/jira/browse/HIVE-466
>             Project: Hadoop Hive
>          Issue Type: Bug
>          Components: Query Processor
>    Affects Versions: 0.3.1, 0.4.0
>            Reporter: Zheng Shao
>            Assignee: Zheng Shao
>             Fix For: 0.4.0
>
>
> There was a bug in the SemanticAnalyzer that adds the columnID for one more time for "*".
> This causes queries like this to fail:
> {code}
> create table zshao_lazy (a int);
> // load one row of data into zshao_lazy
> select * from (select *, a as a2 from zshao_lazy) z order by a2 limit 10;
> {code}
> The query will fail at execution time.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.