[英]Hive: Need to specify partition columns because the destination table is partitioned
我不知道是否有可能在蜂巢中插入一個非分區表成被分區之一。 第一個表如下:
hive> describe extended user_ratings;
OK
userid int
movieid int
rating int
unixtime int
Detailed Table Information Table(tableName:user_ratings, dbName:ml, owner:cloudera, createTime:1500142667, lastAccessTime:0, retention:0, sd:StorageDescriptor(cols:[FieldSchema(name:userid, type:int, comment:null), FieldSchema(name:movieid, type:int, comment:null), FieldSchema(name:rating, type:int, comment:null), FieldSchema(name:unixtime, type:int, comment:null)], location:hdfs://quickstart.cloudera:8020/user/hive/warehouse/ml.db/user_ratings, inputFormat:org.apache.hadoop.mapred.TextInputFormat, outputFormat:org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat, compressed:false, numBuckets:-1, serdeInfo:SerDeInfo(name:null, serializationLib:org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, parameters:{serialization.format= , field.delim=
Time taken: 0.418 seconds, Fetched: 6 row(s)
因此,新表為:
hive> describe extended rating_buckets;
OK
userid int
movieid int
rating int
unixtime int
genre string
# Partition Information
# col_name data_type comment
genre string
Detailed Table Information Table(tableName:rating_buckets, dbName:default, owner:cloudera, createTime:1500506879, lastAccessTime:0, retention:0, sd:StorageDescriptor(cols:[FieldSchema(name:userid, type:int, comment:null), FieldSchema(name:movieid, type:int, comment:null), FieldSchema(name:rating, type:int, comment:null), FieldSchema(name:unixtime, type:int, comment:null), FieldSchema(name:genre, type:string, comment:null)], location:hdfs://quickstart.cloudera:8020/user/hive/warehouse/rating_buckets, inputFormat:org.apache.hadoop.mapred.TextInputFormat, outputFormat:org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat, compressed:false, numBuckets:8, serdeInfo:SerDeInfo(name:null, serializationLib:org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, parameters:{serialization.format= , field.delim=
Time taken: 0.46 seconds, Fetched: 12 row(s)
似乎正在將分區(“類型”)視為與其他列相同...我可能創建錯了嗎?
無論如何,這是當我嘗試對新表執行INSERT OVERWRITE時發生的情況:
hive> FROM ml.user_ratings
> INSERT OVERWRITE TABLE rating_buckets
> select userid, movieid, rating, unixtime;
FAILED: SemanticException 2:23 Need to specify partition columns because the destination table is partitioned. Error encountered near token 'rating_buckets'
我應該只重新創建帶有分區的第一個表嗎? 有沒有辦法復制第一個表並保持分區不變?
您甚至沒有在選擇列表中包括流派。 我認為它必須排在最后。 您不能一無所有。
您還需要使用表指定分區,如下所示:
insert overwrite table ratings_buckets partition(genre)
select
userid,
movieid,
rating,
unixtime,
<SOMETHING> as genre
from
...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.