Using hive function xpath,xpath_string
step 1: Create single column table
create table xmldataTable(col1 string);
step 2 : Load data into single column table
load data local inpath 'xmldata' into table xmldataTable;
step 3: create the required table
create table xml_table2(name string, age int,gend string);
insert overwrite table xml_table2 select xpath_string(col1, 'rec/name'),xpath_string(col1, 'rec/age'),xpath_string(col1,'rec/sex ') from xmldataTable ;
hive> select * from (select * from emp unionall select * from emp2)e
[cloudera@localhost ~]> hive -e 'select eid from emp'
Running hive scripts
[cloudera@localhost ~]$ gedit hivesc.hive
hivesc.hive file
use nareshdb;
[cloudera@localhost ~]$ hive -f hivesc