Search This Blog

Saturday 18 February 2017

Loading map and structures collections in to hive table

MAP DATA EXPERIMENT::

table creation:

hive> create table mapt(name string,ded map<string,float>)
    > row format delimited
    >fields terminated by '\t'
    > collection items terminated by ':'
    > map keys terminated by '='
    >lines terminated by '\n'
    >stored as textfile;


mapdata.txt:

rao     da=0.2:pf=0.3:hra=0.2



Access Map data:
hive> select ded["pf"] from mapt;
Total MapReduce jobs = 1
Launching Job 1 out of 1
-----------------
--------------
--------------
2017-02-18 12:41:03,728 Stage-1 map = 100%,  reduce = 100%
Ended Job = job_201702181008_0003
OK
0.3
Time taken: 8.433 seconds

-----------------------------------------------------------------------

STRUCTURE DATA EXPERIMENT:


table creation:


hive> create table strut(                        
    > name string,                                
    > address struct<city:string, state:string, pin:int>)
    > row format delimited                              
    > fields terminated by '\t'                        
    > collection items terminated by ','                
    > lines terminated by '\n'                          
    > stored as textfile;                              
OK


strdata.txt:

[training@localhost ~]$ cat > strdata.txt
sekhar  jj,ap,521006




Access structure data:

hive> select address.city from strut;

op:
------------------------
----------------------------
2017-02-18 13:01:28,173 Stage-1 map = 0%,  reduce = 0%
2017-02-18 13:01:30,205 Stage-1 map = 100%,  reduce = 0%
2017-02-18 13:01:32,230 Stage-1 map = 100%,  reduce = 100%
Ended Job = job_201702181008_0004
OK
jj
Time taken: 8.323 seconds








No comments:

Post a Comment

Hadoop Analytics

NewolympicData

  Alison Bartosik 21 United States 2004 08-29-04 Synchronized Swimming 0 0 2 2 Anastasiya Davydova 21 Russia 2004 0...