Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: move Logging section, add link to logging in Getting Started, edit whitespace

...

  • Example of running a query from the command line

    No Format
       $HIVE_HOME/bin/hive -e 'select a.col from tab1 a'
       
  • Example of setting Hive configuration variables

    No Format
       $HIVE_HOME/bin/hive -e 'select a.col from tab1 a' --hiveconf hive.exec.scratchdir=/home/my/hive_scratch  --hiveconf mapred.reduce.tasks=32
       
  • Example of dumping data out from a query into a file using silent mode

    No Format
       $HIVE_HOME/bin/hive -S -e 'select a.col from tab1 a' > a.txt
       
  • Example of running a script non-interactively from local disk

    No Format
       $HIVE_HOME/bin/hive -f /home/my/hive-script.sql
       
  • Example of running a script non-interactively from a Hadoop supported filesystem (starting in Hive 0.14)

    No Format
       $HIVE_HOME/bin/hive -f hdfs://<namenode>:<port>/hive-script.sql
       $HIVE_HOME/bin/hive -f s3://mys3bucket/s3-script.sql 
  • Example of running an initialization script before entering interactive mode

    No Format
       $HIVE_HOME/bin/hive -i /home/my/hive-init.sql
       

The hiverc File

The CLI when invoked without the -i option will attempt to load $HIVE_HOME/bin/.hiverc and $HOME/.hiverc as initialization files.

Logging

Hive uses log4j for logging. These logs are not emitted to the standard output by default but are instead captured to a log file specified by Hive's log4j properties file. By default Hive will use hive-log4j.default in the conf/ directory of the Hive installation which writes out logs to /tmp/<userid>/hive.log and uses the WARN level.

It is often desirable to emit the logs to the standard output and/or change the logging level for debugging purposes. These can be done from the command line as follows:

No Format
 $HIVE_HOME/bin/hive --hiveconf hive.root.logger=INFO,console

hive.root.logger specifies the logging level as well as the log destination. Specifying console as the target sends the logs to the standard error (instead of the log file).

See Hive Logging in Getting Started for more information.

Hive Batch Mode Commands

...

No Format
  hive> set mapred.reduce.tasks=32;
  hive> set;
  hive> select a.* from tab1;
  hive> !ls;
  hive> dfs -ls;

Logging

Hive uses log4j for logging. These logs are not emitted to the standard output by default but are instead captured to a log file specified by Hive's log4j properties file. By default Hive will use hive-log4j.default in the conf/ directory of the Hive installation which writes out logs to /tmp/<userid>/hive.log and uses the WARN level.

...