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 Threaded View
Hive >> mail # user >> Best way to create a view with index from explode ?


Copy link to this message
-
Best way to create a view with index from explode ?
Hi all,

I have an input table which has 3 columns one of which is an array list,

 

bcookie, id, info [Schema: string, string,
arraylist<map<string,string>>]

 

Here is a sample row

 

1245, 1, {[myid#id2, myage#100], [myid#id3, myage#101], [myid#id3,
myage#102]}

 

I wanted to explode the arraylist column and create an additional column
which represents the index of the info

 

bcookie, id, info, index

1245, 1, [myid#id2, myage#100], 0

1245, 1, [myid#id3, myage#101], 1

1245, 1, [myid#id3, myage#102] , 2

 

I was thinking of the lines of:

SELECT * FROM srctable LATERAL VIEW explode(info)... ;

 

Is UDTF the only way to achieve this?

Thanks Viraj

 

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