简体   繁体   中英

Hive - Insert data into partitioned table: partition not found

I'm having issue while trying to inserting new data in Hive external partitioned table.

Table is partitioned by day, the error I got is:

FAILED: SemanticException [Error 10006]: Line 1:51 Partition not found ''18102016''

My query is as following:

ALTER TABLE my_source_table RECOVER PARTITIONS;
INSERT OVERWRITE TABLE my_dest_table PARTITION (d = '18102016')
SELECT
  'III' AS primary_alias_type,
   iii_id AS primary_alias_id,
FROM
   my_source_table
WHERE 
   d = '18102016'

The my_dest_table has been created as:

CREATE EXTERNAL TABLE my_dest_table (
   primary_alias_type string,
   primary_alias_id
) PARTITIONED BY (d string)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
LOCATION 's3://my_bucket/my_external_tables/'

Any idea on what I'm doing wrong? Thanks!

I believe you should ALTER TABLE my_source_table RECOVER PARTITIONS; do this for your destination table.

ALTER TABLE my_dest_table RECOVER PARTITIONS;

try this.

Note: Of course you should remove the extra comma what Alex L mentioned. Which will give other parsing error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM