Monday, 14 August 2017

3)Hive Commands,CLI(Command Line Interface)

Hive commands:

Commands are useful for setting a property or adding a resource
Commands Table chart:

Command Descripiton
quit or exit Use quit or exit to leave the interactive shell.
reset Resets the configuration to the default values
set <key>=<value> Sets the value of a particular configuration variable (key)
set Prints a list of configuration variables
set -v Prints all Hadoop and Hive configuration variables.
add FILE[S] <filepath> <filepath>*
add JAR[S] <filepath> <filepath>*
add ARCHIVE[S] <filepath> <filepath>*
Adds one or more files, jars, or archives to the list of resources in the distributed cache
add FILE[S] <ivyurl> <ivyurl>*
add JAR[S] <ivyurl> <ivyurl>*
add ARCHIVE[S]<ivyurl> <ivyurl>*
adds one or more files, jars or archives to the list of resources in the distributed cache using an Ivy URL of the form ivy://group:module:version?query_string
list FILE[S]
list JAR[S]
list ARCHIVE[S]
Lists the resources already added to the distributed cache.
list FILE[S] <filepath>*
list JAR[S] <filepath>*
list ARCHIVE[S] <filepath>*
Checks whether the given resources are already added to the distributed cache or not.
delete FILE[S] <filepath>*
delete JAR[S] <filepath>*
delete ARCHIVE[S] <filepath>*
Removes the resource(s) from the distributed cache.
delete FILE[S] <ivyurl> <ivyurl>*
delete JAR[S] <ivyurl> <ivyurl>*
delete ARCHIVE[S] <ivyurl> <ivyurl>*
Removes the resource(s) which were added using the <ivyurl> from the distributed cache.
! <command> Executes a shell command from the Hive shell.
dfs <dfs command> Executes a dfs command from the Hive shell.
<query string> Executes a Hive query and prints results to standard output.
source FILE <filepath> Executes a script file inside the CLI.
compile `<groovy string>` AS GROOVY NAMED <name> This allows inline Groovy code to be compiled and be used as a UDF

Hive CLI(Command Line Interface)

$HIVE_HOME/bin/hive is a shell utility which can be used to run Hive queries in either interactive or batch mode.

Hive Command Line Options:
Syntax:usage on command line: just hit hive


Examples:
1)Running a query from the command line with -e <quoted-query-string>  

mano@Mano:~$ hive -e 'select * from students'
 
2)Setting Hive configuration variables --hiveconf

mano@Mano:~$ hive -e 'select * from students' --hiveconf hive.cli.print.header=false


Note: The variant "-hiveconf" is supported as well as "--hiveconf".

3)Dumping data out from a query into a file 

mano@Mano:~$ hive -e 'select * from students'> /home/mano/DataSets/students.txt



using silent mode -S,--silent  


4)Running a script from local disk using -f <filepath> 

hive -f <filepath>
<filepath> can be from one of the Hadoop supported filesystems (HDFS, S3, etc.) as well

hive -f /home/my/hive-script.sql

hadoop@Manohar:~$ hive -f hdfs://localhost:9000/Hive_Script/hdfs_script.sql

5)Running an initialization script before entering interactive mode

hive -i /home/my/hive-init.sql

  Previous page               Next page

1 comment:

Fundamentals of Python programming

Fundamentals of Python programming: Following below are the fundamental constructs of Python programming: Python Data types Python...