Hive query question

I have a table in hive:
table1
f1  f2
x   10
y 20
p 40
q 55

How can I query the above table in hive to obtain one record like the following:
x:10, y:20, p:40, q:55

Thank you.
toookiAsked:
Who is Participating?
 
SharathConnect With a Mentor Data EngineerCommented:
You need COLLECT_SET function. try this.
SELECT COLLECT_SET(Col) AS Res_Col
  FROM (SELECT CONCAT(f1,':',f2) AS Col
		  FROM table1) T1

Open in new window

0
 
aikimarkCommented:
Are you talking about the Windows registry hive or some other database?

What language are you using?
0
 
toookiAuthor Commented:
I am using Apache Hive.
0
 
mlmccCommented:
In looking at the Hive language manual it uses fairly standard SQL

SELECT * FROM sales WHERE amount > 10 AND region = "US"

Link to the language manual
https://cwiki.apache.org/confluence/display/Hive/LanguageManual

mlmcc
0
 
aikimarkCommented:
My guess would be some combination of ClusterBy and Transform, however, I have no way to test this.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.