create table hivecomplex
(name string,
phones array<INT>,
deductions map<string,float>,
address struct<street:string,zip:INT>
)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
COLLECTION ITEMS TERMINATED BY '$'
MAP KEYS TERMINATED BY '#'
STORED AS AVRO
;
hive> select * from hivecomplex;
OK
John [650,999,9999] {"pf":500.0} {"street":"pleasantville","zip":88888}
Time taken: 0.078 seconds, Fetched: 1 row(s)
Now for the pig
pig -useHCatalog;
a = LOAD 'hivecomplex' USING org.apache.hive.hcatalog.pig.HCatLoader();
dump a;
ne.util.MapRedUtil - Total input paths to process : 1
(John,{(650),(999),(9999)},[pf#500.0],(pleasantville,88888))
感謝您的答覆。你的例子正在工作。我在我的hive_avro表中使用了複雜的數據類型(Array,Map和Struct)。看起來像Struct數據類型導致了問題。有什麼想法嗎? –
豬中支持複雜的數據類型。可以創建另一個關係使用LIMIT 5並轉儲該關係。 hive_avro_table是配置單元表還是視圖?豬不支持視圖。如果hive_avro_table是位置上的外部表檢查權限,並且也是/ tmp –