Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Plain View
Hive >> mail # user >> Converting rows into dynamic colums in Hive


+
richin.jain@... 2012-08-07, 20:57
Copy link to this message
-
Re: Converting rows into dynamic colums in Hive
you should be able to do this in hive using a group by on alpha and then
using a combination of the max and if statement... something on the
following lines

select alpha, max(abc), max(pqr), ...
(
  select alpha, if (beta == 'abc', Gamma, NULL) as abc, if (beta == 'pqr',
Gamma, NUL) as pqr, ....
  from table
)
group by alpha

something on those lines...

Ashish

On Tue, Aug 7, 2012 at 1:57 PM, <[EMAIL PROTECTED]> wrote:

>  Hi All,****
>
> ** **
>
> One of my Query output looks like-****
>
> ** **
>
> *Alpha                    Beta                       Gamma*
>
> 123                         xyz                         1.0****
>
> 123                         abc                         0.5****
>
> 123                         pqr                         1.3****
>
> 123                         def                         2.1****
>
> *456                         xyz                         0.1*
>
> *456                         abc                         0.6*
>
> *456                         pqr                         1.9*
>
> *456                         def                         3.2*
>
> *456                         lmn                        1.1*
>
> *456                         sdf                          1.2*
>
> ** **
>
> I want the output for the data visualization purpose to look like
> (basically taking rows from one table and making it column in another table)
> ****
>
> ** **
>
> *Alpha                    xyz         abc         pqr         def
> lmn        sdf          *
>
> 123                         1.0          0.5          1.3
> 2.1                                          ****
>
> 456                         0.1          0.6          1.9
> 3.2          1.1          1.2****
>
> ** **
>
> Question – Can it be done in Hive? If not, any suggestions.****
>
> ** **
>
> Thanks,****
>
> Richin****
>
> ** **
>
> ** **
>
+
richin.jain@... 2012-08-08, 19:56
+
John Meagher 2012-08-08, 20:34
+
richin.jain@... 2012-08-09, 00:58
+
John Meagher 2012-08-09, 14:10
+
richin.jain@... 2012-08-09, 20:16
+
richin.jain@... 2012-08-16, 14:39
+
Raghunath, Ranjith 2012-08-07, 21:00
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB