Solved

Hive query question

Posted on 2014-02-14
5
221 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 45

Expert Comment

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

What language are you using?
0
 

Author Comment

by:toooki
ID: 39860989
I am using Apache Hive.
0
 
LVL 101

Expert Comment

by:mlmcc
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
https://cwiki.apache.org/confluence/display/Hive/LanguageManual

mlmcc
0
 
LVL 45

Expert Comment

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

Accepted Solution

by:
Sharath earned 500 total points
ID: 39932206
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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

690 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