Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
STEP 1 : CREATING INPUT XML FILE WHICH WE WILL LOAD IN HIVE TABLE
nano student.xml
<student> <id>1</id> <name>Milind</name> <age>25</age> </student>
<student> <id>2</id> <name>Ramesh</name> <age>Testing</age> </student>
STEP 2 : LOG IN TO HIVE
hive
STEP 3 : CREATING HIVE TABLE
create table student_xml( studinfo string) ;
STEP 4 : LOADING DATA INTO HIVE TABLE
load data local inpath '/home/hduser/student.xml' into table student_xml;
STEP 5 : QUERYING THE LOADED DATA
select * from student_xml;
STEP 6 : CREATING A VIEW ON TOP OF NEWLY CREATED HIVE TABLE FOR GETTING NEWLY ADDED RECORDS
create view student_xml_view as SELECT xpath_int(studinfo ,'student/id'),xpath_string(studinfo ,'student/name'),xpath_string(studinfo ,'student/age') FROM student_xml;
STEP 7 : QUERYING THE CREATED VIEW
select * from student_xml_view;
STEP 8 : ADDING ONE MORE FILE TO CHECK VIEW FUNCTIONALITY
load data local inpath '/home/hduser/student.xml' into table student_xml;
STEP 9 : QUERYING VIEW FOR INCREMENTAL RECORDS
select * from student_xml_view;
@milindjagre

This comment has been minimized.

Copy link
Owner Author

@milindjagre milindjagre commented May 9, 2016

This is a text file which contains all the commands that I ran while loading XML file into Hive Table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment