Hive query question

Posted on 2014-02-14
Last Modified: 2014-03-17
I have a table in hive:
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.
Question by:toooki
LVL 45

Expert Comment

ID: 39860408
Are you talking about the Windows registry hive or some other database?

What language are you using?

Author Comment

ID: 39860989
I am using Apache Hive.
LVL 100

Expert Comment

ID: 39861420
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

LVL 45

Expert Comment

ID: 39862084
My guess would be some combination of ClusterBy and Transform, however, I have no way to test this.
LVL 40

Accepted Solution

Sharath earned 500 total points
ID: 39932206
You need COLLECT_SET function. try this.
  FROM (SELECT CONCAT(f1,':',f2) AS Col
		  FROM table1) T1

Open in new window


Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Change variables in SQL table 6 81
SQL QUERY to Table question 32 83
Compare and update data between two databases 6 58
oracle query help 18 99
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
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…

912 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

22 Experts available now in Live!

Get 1:1 Help Now