我有一个Text Format配置单元表,如:
CREATE EXTERNAL TABLE op_log (
time string, debug string,app_id string,app_version string, ...more fields)
PARTITIONED BY (dt string)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
STORED AS TEXTFILE;
现在我创建一个具有相同字段的orc格式表,例如
CREATE TABLE op_log_orc (
time string, debug string,app_id string,app_version string, ...more fields)
PARTITIONED BY (dt string)
STORED AS ORC tblproperties ("orc.compress" = "SNAPPY");
当我从op_log
复制到op_log_orc
时,我收到了这个错误:
hive> insert into op_log_orc PARTITION(dt='2016-08-09') select * from op_log where dt='2016-08-09';
FAILED: SemanticException [Error 10044]: Line 1:12 Cannot insert into target table because column number/types are different ''2016-08-09'': Table insclause-0 has 62 columns, but query has 63 columns.
hive>
答案 0 :(得分:0)
源表中的分区键(dt
)在结果集中返回,就像它是常规字段一样,因此您有额外的列。如果您要在分区键中指定其值,请从字段列表中排除dt
字段(而不是*
)。或者,只需指定dt
作为分区的名称,而不提供值。请参阅此处示例中的CTAS(将表创建为选择...):https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-CreateTableAsSelect(CTAS)