Adding data to ARRAY Type

Hive supports 2 categories of data type ; Simple & Complex. In this post, we will see how to add data to an ARRAY Type(Complex type). ARRAY type is populated using the built-in function array()

Let us see how we can load the data into marks field which is of type array
hive > desc maths;
name                 string
class                string
marks                array<string> 
Our source data for the maths table is available in table Subjects
hive> desc subjects;
name                 string
class                string
history              string
geography            string
botany               string
zoology              string
algebra              string
trigonometry         string
tamil                string
english              string
hive> select * from subjects;
name1 XI 60 65 70 75 80 85 90 95
name2 XI 61 66 71 76 81 86 91 96
insert overwrite table maths
select name, class, array(algebra, trigonometry) from subjects;
hive> select * from maths;
name1 XI ["80","85"]
name2 XI ["81","86"]

3 comments:


  1. very informative blog and useful article thank you for sharing with us , keep posting Big data hadoop online Course

    ReplyDelete
  2. I would like to say thank you for this special website. . keep writing such an informative blog. The visa for Turkey is open and you Explore Turkey easily in this modern era e visa facility is also very popular.It helps to save time in other physical visa activities .

    ReplyDelete