Marking display based on the user's image "column to row" feature

Source: Internet
Author: User

First, the question

How Hive will

1 represents the user, a represents the user's attributes, and the 0/1/0 represents the characteristic value

1 A1 0
1 A2 1
1 A3 0


1 a1,0 a2,1 a3,0

Second, the data

Split with \ t

[Jiangzl@master tmp]$ Cat Jiangzl.txt
1 A1 0
1 A2 1
1 A3 0

Third, the answer

1. Build a table

drop table iangzl_test;

CREATE TABLE Jiangzl_test (
col1 int,
Col2 string,
col3 int
Row format delimited
Fields terminated by ' \ t '
stored as textfile;

Load data local inpath '/home/jiangzl/work/tmp/jiangzl.txt ' into table default.jiangzl_test;

2. Handling

Select col1, Data[0], data[1], data[2]
From (
Select col1, Collect_set (Concat_ws (', ', col2, cast (col3 as String)) data
From Jiangzl_test
) T;

Iv. About Us

This article author: one of the pioneer members of the data Jiang Zhong Lian

QQ Group: 248087140


you're in the field you're good at,

and with a group of small white change

others will respect you from the heart.

--Click to join US

Marking display based on the user's image "column to row" feature

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.