Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# Assuming we are using hduser for doing Hadoop Operations
cd /home/hduser
# Loading .bashrc file in order to access HIVE Installation Directory Path
source .bashrc
# Removing already existing CSV SERDE JAR FILE
rm csv-serde-1.1.2-0.11.0-all.jar
# Downloading CSV SERDE JAR FILE during run time
# Copying Downloaded CSV SERDE FILE to HIVE lib Directory
cp csv-serde-1.1.2-0.11.0-all.jar $HIVE_HOME/lib
# Creating Input Data File
echo "column1,column2" > input.txt
echo "1,this is first line" >> input.txt
echo "2,this is second line" >> input.txt
# Creating Hive Table by using CSV SERDE and skipping the first line since it is an header. At last printing records in hive table.
hive -e "drop table csvtohive;create table csvtohive(column1 string,column2 string) row format serde 'com.bizo.hive.serde.csv.CSVSerde' stored as textfile tblproperties ('skip.header.line.count'='1');LOAD DATA LOCAL INPATH '/home/hduser/input.txt' INTO TABLE csvtohive;select * from csvtohive;"

This comment has been minimized.

Copy link
Owner Author

@milindjagre milindjagre commented May 6, 2016

This file will load csv data in hive table and at last print the records inserted in hive table

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.