2016-08-09 41 views
0

ich habe eine Text Format hive Tabelle, wie TEXT-Format partitionierten Tabelle ORC-Format Tabelle kopieren: i create table ein Ork-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; Wie in Hive

jetzt mit denselben Feldern, wie 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");

wenn ich op_log-op_log_orc kopieren, habe ich diese Fehlermeldungen erhalten:

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>

Antwort

0

Der Verteilungsschlüssel (dt) in der Quelltabelle wird in der Ergebnismenge zurückgegeben, als ob es ein reguläres Feld wäre, also haben Sie die zusätzliche Spalte. Schließen Sie das Feld dt aus der Feldliste aus (anstelle von *), wenn Sie seinen Wert im Partitionsschlüssel angeben möchten. Alternativ geben Sie einfach dt als Namen der Partition an, ohne einen Wert anzugeben. Siehe CTAS (Tabelle als Auswahl erstellen ...) im Beispiel hier: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-CreateTableAsSelect(CTAS)