Create a new table
The table statement is as follows:
CREATE TABLE IF not EXISTS user_collection_9 (
user_id string,
seller_id string,
product_id string,
Tim E string
)
Import data to hive in Hue
First, in the file browser, the text that you created the table is directed in, as shown in the following illustration:
Use the following action statement to import text data into hive.
Hive The selected table data into a new table
Since my three table structure is the same, the following action statement is used directly.
CREATE TABLE User_port as SELECT * from user_collection_7 UNION ALL SELECT * to user_collection_8 UNION ALL SELECT * FRO M User_collection_9
connection functions in hive
In hive, Group_concat cannot be used and CONCAT_WS is used.
CREATE table user_collection_port as select IP as User_id,concat_ws (', Collect_set (product_id)) as product from User_coll Ection_taobao_allall GROUP by IP has count (*) >2;
The result of using this function is to connect each user's data together, separated by spaces in the middle, as shown in the following illustration:
hue the data in hive to local
The following table structure is the same as the previous image, so the two columns are directly delimited using tabs, and you will find that in the "/user/qianyang/" directory, there are
Insert overwrite directory '/user/qianyang/' row format delimited fields terminated by ' \ t ' select * from User_789coll ection;
You can browse some of this data online.
Export to Windows
The table data can be downloaded to the local area as shown in the following illustration.