insert values for complicated structure in hive
My hive table has the complicated structure as columns such as array and struct.
for example, the table definition:
hive> desc books;
OK
id int
name string
lang struct<eng:int,chn:int>
types array<string>
price float
Time taken: 0.234 seconds, Fetched: 5 row(s)
To insert the values for columns lang and types, I have to use the dummy syntax as follows.
hive> insert into books select 101,"learning spring boot",NAMED_STRUCT("eng",1,"chn",0),array("programming","web"),29.99;
To select the last inserted values:
hive> select * from books order by id desc limit 1;
101 learning spring boot {"eng":1,"chn":0} ["programming","web"] 29.99
Time taken: 2.45 seconds, Fetched: 1 row(s)