Home > Enterprise >  How to select only some values form dictionary in one of column of hive table?
How to select only some values form dictionary in one of column of hive table?

Time:09-16

Suppose this is my hive table

A B C
a1 {'age':0,'name':b1, 'id':100} c1
a2 {'age':1,'name':b2, 'id':200} c2
a3 {'age':2,'name':b3, 'id':300} c3
How to select only this
age name
0 b1
1 b2
2 b3
using SQL query on hash table

CodePudding user response:

To get the result you wanted you can use the following query:

SELECT get_json_object(B,'$.age')  as age,
       get_json_object(B,'$.name') as name
FROM table_name

Where B is your column name

  • Related