Hive tips and shortcuts

#execute a query in Silent(S)Mode

 
 
  1. hive -S -e "your hive query"

#execute a query

 
 
  1. hive -e "your hive query"

 

#show current database

 
 
  1. hive>SET hive.cli.print.CURRENT.db=TRUE;

 

#show all column names for a table

 
 
  1. hive>SET hive.cli.print.header=TRUE;

 

#to run all pre required commands in one go

1.create .hiverc file in your root directory.

2.put all commands in .hiverc file.

Now all commands will run when you enter in to hive.

 

#run shell commands without exiting hive

  1. put ! before shell commands.

Examples:-

 
 
  1. hive> ! hadoop fs -ls ;
  2. hive> ! ls ;

 

#run a hql file in Hive CLI

 
 
  1. hive> SOURCE <location_Of/hql_File>

 

#run a hql file in unix:

 
 
  1. hive -f <location_Of/hql_File>

 

#you can save hive query file with extension .q or .hql;

 

Load CSV file into hive AVRO table

Requirement You have comma separated(CSV) file and you want to create Avro table in hive on top of it, then ...
Read More

Load CSV file into hive PARQUET table

Requirement You have comma separated(CSV) file and you want to create Parquet table in hive on top of it, then ...
Read More

Hive Most Asked Interview Questions With Answers – Part II

What is bucketing and what is the use of it? Answer: Bucket is an optimisation technique which is used to ...
Read More
/ hive, hive interview, interview-qa

Spark Interview Questions Part-1

Suppose you have a spark dataframe which contains millions of records. You need to perform multiple actions on it. How ...
Read More

Leave a Reply