Hive non-interactive mode and hive Mode

Source: Internet
Author: User

Hive non-interactive mode and hive Mode

Run $ HIVE_HOME/bin/hive on a linux terminal to enter the interaction mode;

$ HIVE_HOME/bin/hive-e or-f is in non-interactive mode.

1. Execute HQL statements in non-interactive mode

$HIVE_HOME/bin/hive  -e 'select * from movie limit 10'
The progress of mapreduce is displayed, but the hive interaction mode is not displayed. The final query result is


2. Execute HQL statements in non-interactive mode (-S mute mode)

$HIVE_HOME/bin/hive -S -e 'select * from movie limit 10'
Adding the-S option does not display the mapreduce progress

[hadoop@gaoyuan hive-0.14]$ bin/hive -S -e 'select * from movie limit 10'SLF4J: Class path contains multiple SLF4J bindings.SLF4J: Found binding in [jar:file:/home/hadoop/hadoop-2.4.0/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]SLF4J: Found binding in [jar:file:/home/hadoop/hive-0.14/lib/hive-jdbc-0.14.0-SNAPSHOT-standalone.jar!/org/slf4j/impl/StaticLoggerBinder.class]SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]Error rolling back: Can't call rollback when autocommit=true1113382172063197110411095751161610611978771214588122118913751710140623


3. Export hive query to a file

$HIVE_HOME/bin/hive -S -e 'select * from movie limit 10' > /gaoyuan/ouput.txt
This will import the execution result of the hivequery statement to the output.txt file.


4. Run the hive script instead of entering hive interaction mode.

$HIVE_HOME/bin/hive -f hiveScript.sql    

You can also save the output result to a file.

$ HIVE_HOME/bin/hive-f hiveScript. SQL>/home/username/output.txt

 










The differences between Interactive shell and non-interactive shell

In interactive mode, shell waits for your input and runs the command you submit. This mode is called interactive because shell interacts with users. This mode is also very familiar to most users: logon, command execution, and logout. When you sign back, shell is terminated.
Shell can also run in another mode: non-interactive mode. In this mode, shell does not interact with you, But reads commands stored in files and runs them. When it reads the end of the file, shell is terminated.

What is Hive?

In addition, hive supports developers familiar with map-reduce to use the map-reduce program to perform more complex data analysis. Hive can combine thrift with control delimiters, and supports custom delimiters. Hive is based on hadoop. hadoop is a batch processing system and cannot store low latency. Therefore, hive queries cannot guarantee low latency. Hive works in the following mode: Submit a task and be notified when the task ends, instead of querying in real time. Correspondingly, a system like Oracle responds very quickly when it runs on a small data set. However, it may take several hours to process a large data set. It should be noted that hive may take several minutes to complete even if it runs on a small dataset. Low latency is not the primary goal of hive.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.