Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Plain View
Hive >> mail # dev >> Review Request: HIVE-4032:Inserting data into Hive table from a query, when the query is a partitioned table and select * , will generate a SemanticException


Copy link to this message
-
Review Request: HIVE-4032:Inserting data into Hive table from a query, when the query is a partitioned table and select * , will generate a SemanticException

-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/10234/
-----------------------------------------------------------

Review request for hive.
Description
-------

See: https://issues.apache.org/jira/browse/HIVE-4032
This addresses bug HIVE-4032.
    https://issues.apache.org/jira/browse/HIVE-4032
Diffs
-----

  http://svn.apache.org/repos/asf/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java 1463367

Diff: https://reviews.apache.org/r/10234/diff/
Testing
-------

Before fix :
hive (default)> explain                                                                                        
              > insert into table zr_test partition (dt='20130217') select * from zr_test_1 where dt='20130217';
FAILED: SemanticException [Error 10044]: Line 2:18 Cannot insert into target table because column number/types are different ''20130217'': Table insclause-0 has 2 columns, but query has 3 columns.

After fix:
hive (default)> explain
              > insert into table zr_test partition (dt='20130217') select * from zr_test_1 where dt='20130217';
[2013-04-02 12:33:12]: Compile Start
[2013-04-02 12:33:15]: Compile End
[2013-04-02 12:33:15]: OK
ABSTRACT SYNTAX TREE:
  (TOK_QUERY (TOK_FROM (TOK_TABREF (TOK_TABNAME zr_test_1))) (TOK_INSERT (TOK_INSERT_INTO (TOK_TAB (TOK_TABNAME zr_test) (TOK_PARTSPEC (TOK_PARTVAL dt '20130217')))) (TOK_SELECT (TOK_SELEXPR TOK_ALLCOLREF)) (TOK_WHERE (= (TOK_TABLE_OR_COL dt) '20130217'))))

STAGE DEPENDENCIES:
  Stage-1 is a root stage
  Stage-5 depends on stages: Stage-1 , consists of Stage-4, Stage-3
  Stage-4
  Stage-0 depends on stages: Stage-4, Stage-3
  Stage-2 depends on stages: Stage-0
  Stage-3

STAGE PLANS:
  Stage: Stage-1
    Map Reduce
      Alias -> Map Operator Tree:
        zr_test_1
          TableScan
            alias: zr_test_1
            Filter Operator
              predicate:
                  expr: (dt = '20130217')
                  type: boolean
              Select Operator
                expressions:
                      expr: key
                      type: string
                      expr: value
                      type: string
                      expr: dt
                      type: string
                outputColumnNames: _col0, _col1, _col2
                File Output Operator
                  compressed: false
                  GlobalTableId: 1
                  table:
                      input format: org.apache.hadoop.mapred.TextInputFormat
                      output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat
                      serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
                      name: default.zr_test

  Stage: Stage-5
    Conditional Operator

  Stage: Stage-4
    Move Operator
      files:
          hdfs directory: true
          destination: hdfs://hd17-vm5:9101/user/zongren/hive-scratchdir/hive_2013-04-02_12-33-12_425_5386104740729125/-ext-10000

  Stage: Stage-0
    Move Operator
      tables:
          partition:
            dt 20130217
          replace: false
          table:
              input format: org.apache.hadoop.mapred.TextInputFormat
              output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat
              serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
              name: default.zr_test

  Stage: Stage-2
    Stats-Aggr Operator

  Stage: Stage-3
    Map Reduce
      Alias -> Map Operator Tree:
        hdfs://hd17-vm5:9101/user/zongren/hive-scratchdir/hive_2013-04-02_12-33-12_425_5386104740729125/-ext-10002
            File Output Operator
              compressed: false
              GlobalTableId: 0
              table:
                  input format: org.apache.hadoop.mapred.TextInputFormat
                  output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat
                  serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
                  name: default.zr_test
[2013-04-02 12:33:15]: Time taken: 3.001 seconds
Thanks,

fangkun cao