Skip to content

Instantly share code, notes, and snippets.

@milindjagre
Created May 6, 2016 09:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save milindjagre/8590f03ef0a19f6d5771ea5604cb7a91 to your computer and use it in GitHub Desktop.
Save milindjagre/8590f03ef0a19f6d5771ea5604cb7a91 to your computer and use it in GitHub Desktop.
# 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
wget https://drone.io/github.com/ogrodnek/csv-serde/files/target/csv-serde-1.1.2-0.11.0-all.jar
# 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 "1,this is first line" > input.txt
echo "2,this is second line" >> input.txt
# Creating Hive Table by using CSV SERDE. 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;LOAD DATA LOCAL INPATH '/home/hduser/input.txt' INTO TABLE csvtohive;select * from csvtohive;"
@milindjagre
Copy link
Author

This script will load CSV data file (without header) into hive table called csvtohive.

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