Solved

Hive query question

Posted on 2014-02-14
5
213 Views
Last Modified: 2014-03-17
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.
0
Comment
Question by:toooki
5 Comments
 
LVL 45

Expert Comment

by:aikimark
Comment Utility
Are you talking about the Windows registry hive or some other database?

What language are you using?
0
 

Author Comment

by:toooki
Comment Utility
I am using Apache Hive.
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
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
 
LVL 45

Expert Comment

by:aikimark
Comment Utility
My guess would be some combination of ClusterBy and Transform, however, I have no way to test this.
0
 
LVL 40

Accepted Solution

by:
Sharath earned 500 total points
Comment Utility
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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

APEX (Application Express) is used to develop a web application from Oracle. SQL Workshop is one of the tools that comes with Oracle APEX to query or modify the database objects or to make any changes to the structure.
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now