[英]Loading data into Hive table
CREATE TABLE IF NOT EXISTS TestingTable2
(
USER_ID BIGINT,
PURCHASED_ITEM ARRAY<STRUCT<PRODUCT_ID: BIGINT,TIMESTAMPS:STRING>>
) ROW FORMAT
DELIMITED FIELDS TERMINATED BY '-'
collection items terminated by ','
map keys terminated by ':'
LINES TERMINATED BY '\n'
STORED AS TEXTFILE
LOCATION '/user/rkost/output2';
Below is my data which is in only one row data that I need to upload it in above table. 以下是我的数据,该数据仅是一行数据,我需要在上表中将其上传。
1015826235-[{"product_id":220003038067,"timestamps":"1340321132000"},{"product_id":300003861266,"timestamps":"1340271857000"},{"product_id":140002997245,"timestamps":"1339694926000"},{"product_id":200002448035,"timestamps":"1339172659000"},{"product_id":260003553381,"timestamps":"1339072514000"}]-
After uploading the data when I do select query, I am not seeing data correctly. 当我选择查询后上传数据后,我看不到正确的数据。 I should be getting only one row as below but I am not getting the below result in the table 我应该只得到如下一行,但是在表中却没有得到以下结果
**USER_ID** **PURCHASED_ITEM**
1015826235 [{"product_id":220003038067,"timestamps":"1340321132000"}, {"product_id":300003861266,"timestamps":"1340271857000"}, {"product_id":140002997245,"timestamps":"1339694926000"}, {"product_id":200002448035,"timestamps":"1339172659000"}, {"product_id":260003553381,"timestamps":"1339072514000"}]
Instead of above data, I am getting something like this in my table data after I do select query. 选择查询后,在表数据中得到的是类似上面的数据,而不是上面的数据。 Anything wrong with the delimeter? 计程表有什么问题吗?
1015826235 [{"product_id":null,"timestamps":" 220003038067"},{"product_id":null,"timestamps":" \"1340321132000\"}"},{"product_id":null,"timestamps":"
300003861266"},{"product_id":null,"timestamps":" \"1340271857000\"}"},{"product_id":null,"timestamps":" 140002997245"},
{"product_id":null,"timestamps":" \"1339694926000\"}"},{"product_id":null,"timestamps":" 200002448035"},
{"product_id":null,"timestamps":" \"1339172659000\"}"},{"product_id":null,"timestamps":" 260003553381"},
{"product_id":null,"timestamps":" \"1339072514000\"}]"}]
Can anyone point me what wrong I am doing? 谁能指出我在做什么错?
在产品ID中添加双引号
1015826235-[{"product_id":"220003038067","timestamps":"1340321132000"},{"product_id":"300003861266","timestamps":"1340271857000"},{"product_id":"140002997245","timestamps":"1339694926000"},{"product_id":"200002448035","timestamps":"1339172659000"},{"product_id":"260003553381","timestamps":"1339072514000"}]-
I have figured it out on my own. 我已经自己弄清楚了。 The whole data that needs to be loaded should be somehow like this- 需要加载的整个数据应该像这样-
1015826235-220003038067:1340321132000,300003861266:1340271857000,140002997245:1339694926000,200002448035:1339172659000,260003553381:1339072514000
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.