Created
May 9, 2016 09:31
-
-
Save milindjagre/6e6991a141ac0b52b13e5dc26405a53a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a text file which contains all the commands that I ran while loading XML file into Hive Table.