This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Deleted extra whitespace

...

The Beeline shell works in both embedded mode as well as remote mode. In the embedded mode, it runs an embedded Hive (similar to Hive CLI) whereas remote mode is for connecting to a separate HiveServer2 process over Thrift. Starting in Hive 0.14, when Beeline is used with HiveServer2, it also prints the log messages from HiveServer2 for queries it executes to STDERR. Remote HiveServer2 mode is recommended for production use, as it is more secure and doesn't require direct HDFS/metastore access to be granted for users.

 

Warning

In remote mode HiveServer2 only accepts valid Thrift calls – even in HTTP mode, the message body contains Thrift payloads.

...

You can also specify the connection parameters on commandlinecommand line. This means you can find the command with the connection string from your unix UNIX shell history. 

No Format
% beeline -u jdbc:hive2://localhost:10000/default -n scott -w password_file
Hive version 0.11.0-SNAPSHOT by Apache

Connecting to jdbc:hive2://localhost:10000/default
Info
titleBeeline with NoSASL connection

If you'd like to connect via NOSASL mode, you must specify the authentication mode explicitly:

% bin/beeline
beeline> !connect jdbc:hive2://<host>:<port>/<db>;auth=noSasl hiveuser pass

 

Beeline Commands

Command

Description

!<SQLLine command>

List of SQLLine commands available at http://sqlline.sourceforge.net/.

Example: !quit exits the Beeline client.

...

Use ";" (semicolon) to terminate commands. Comments in scripts can be specified using the "--" prefix.

 

Command

Description

reset

Resets the configuration to the default values.

set <key>=<value>

Sets the value of a particular configuration variable (key).
Note: If you misspell the variable name, Beeline will not show an error.

set

Prints a list of configuration variables that are overridden by the user or Hive.

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. See Hive Resources for more information.

add FILE[S] <ivyurl> <ivyurl>* 
add JAR[S] <ivyurl> <ivyurl>* 
add ARCHIVE[S] <ivyurl> <ivyurl>*
As of Hive 1.2.0, 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. See Hive Resources for more information.

list FILE[S]
list JAR[S]
list ARCHIVE[S]

Lists the resources already added to the distributed cache. See Hive Resources for more information. (As of Hive 0.14.0: HIVE-7592).

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. See Hive Resources for more information.

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>*

As of Hive 1.2.0, removes the resource(s) which were added using the <ivyurl> from the distributed cache. See Hive Resources for more information.

reloadAs of Hive 0.14.0, makes HiveServer2 aware of any jar changes in the path specified by the configuration parameter hive.reloadable.aux.jars.path (without needing to restart HiveServer2). The changes can be adding, removing, or updating jar files.

dfs <dfs command>

Executes a dfs command.

<query string>

Executes a Hive query and prints results to standard output.

 

Beeline Command Options

The Beeline CLI supports these command line options:

...

For versions earlier than 0.14, see the version note above.

 

Connection URL When Zookeeper Service discovery is enabled

...

The <zookeeper quorum> is same as the value of hive.zookeeper.quorum configuration parameter in hive-site.xml/hivserver2-site.xml used by hiveserver2.

 

Named connection URLs

As of Hive 2.1 via

Jira
serverASF JIRA
columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
serverId5aa69414-a9e9-3523-82ec-879b028fb15b
keyHIVE-13670
, Beeline now also supports named url connect strings via usage of environment variables. If you try to do a "!connect" to a name that does not look like a URL, then beeline will attempt to see if there is an env variable called BEELINE_URL_<name>. For instance, if you specify "!connect blue", it will look for BEELINE_URL_BLUE, and use that to connect. This should make it easier for sysadmins to specify env variables for users, and users need not type in the full URL each time to connect.

 

Reconnecting

Traditionally, "!reconnect" has worked to refresh a connection that has already been established. It is not able to do a fresh connect after "!close" has been run. As of Hive 2.1 via 

Jira
serverASF JIRA
columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
serverId5aa69414-a9e9-3523-82ec-879b028fb15b
keyHIVE-13670
, Beeline remembers the last successful connected-to url in a session, and is able to reconnect even after a "!close" has been run. In addition, if a user does a "!save", then this is saved in the beeline.properties file, which then allows "!reconnect" to connect to this saved last-connected-to url across multiple beeline sessions. In addition, this then opens up a possible use of "beeline -r" from the commandline to do a reconnect on startup.

 

Using JDBC

You can use JDBC to access data stored in a relational database or other tabular format.

...

For versions earlier than 0.14, see the version note above.