Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Option

Description

-u <database URL>

The JDBC URL to connect to.

Usage: beeline -u db_URL 

-r

Reconnect to last used URL (if a user has previously used !connect to a URL and used !save to a beeline.properties file).

Usage: beeline -r

Version: 2.1.0 (HIVE-13670)

-n <username>

The username to connect as.

Usage: beeline -n valid_user

-p <password>

The password to connect as.

Usage: beeline -p valid_password

-d <driver class>

The driver class to use.

Usage: beeline -d driver_class

-e <query>

Query that should be executed. Double or single quotes enclose the query string. This option can be specified multiple times.

Usage: beeline -e "query_string"

Support to run multiple SQL statements separated by semicolons in a single query_string: 1.2.0 (HIVE-9877)
Bug fix (null pointer exception): 0.13.0 (HIVE-5765)
Bug fix (--headerInterval not honored): 0.14.0 (HIVE-7647)
Bug fix (running -e in background): 1.3.0 and 2.0.0 (HIVE-6758); workaround available for earlier versions 

-f <file>

Script file that should be executed.

Usage: beeline -f filepath

Version: 0.12.0 (HIVE-4268)
Note: If the script contains tabs, query compilation fails in version 0.12.0. This bug is fixed in version 0.13.0 (HIVE-6359).
Bug fix (running -f in background): 1.3.0 and 2.0.0 (HIVE-6758); workaround available for earlier versions 

-i (or) --init <file or files>

The init files for initialization

Usage: beeline -i /tmp/initfile

Single file:

Version: 0.14.0 (HIVE-6561)

Multiple files:

Version: 2.1.0 (HIVE-11336)

-w (or) --password-file <password file>

The password file to read password from.

Version: 1.2.0 (HIVE-7175)

-a (or) --authType <auth type>

The authentication type passed to the jdbc as an auth property

Version: 0.13.0 (HIVE-5155)

--property-file <file>

File to read configuration properties from

Usage: beeline --property-file /tmp/a

Version: 2.2.0 (HIVE-13964)

--hiveconf property=value

Use value for the given configuration property. Properties that are listed in hive.conf.restricted.list cannot be reset with hiveconf (see Restricted List and Whitelist).

Usage: beeline --hiveconf prop1=value1

Version: 0.13.0 (HIVE-6173)

--hivevar name=value

Hive variable name and value. This is a Hive-specific setting in which variables can be set at the session level and referenced in Hive commands or queries.

Usage: beeline --hivevar var1=value1

--color=[true/false]

Control whether color is used for display. Default is false.

Usage: beeline --color=true

(Not supported for Separated-Value Output formats. See HIVE-9770)

--showHeader=[true/false]

Show column names in query results (true) or not (false). Default is true.

Usage: beeline --showHeader=false

--headerInterval=ROWS

The interval for redisplaying column headers, in number of rows, when outputformat is table. Default is 100.

Usage: beeline --headerInterval=50

(Not supported for Separated-Value Output formats. See HIVE-9770)

--fastConnect=[true/false]

When connecting, skip building a list of all tables and columns for tab-completion of HiveQL statements (true) or build the list (false). Default is true.

Usage: beeline --fastConnect=false

--autoCommit=[true/false]

Enable/disable automatic transaction commit. Default is false.

Usage: beeline --autoCommit=true

--verbose=[true/false]

Show verbose error messages and debug information (true) or do not show (false). Default is false.

Usage: beeline --verbose=true

--showWarnings=[true/false]

Display warnings that are reported on the connection after issuing any HiveQL commands. Default is false.

Usage: beeline --showWarnings=true

--showDbInPrompt=[true/false]

Display the current database name in prompt. Default is false.

Usage: beeline --showDbInPrompt=true

Version: 2.2.0 (HIVE-14123)

--showNestedErrs=[true/false]

Display nested errors. Default is false.

Usage: beeline --showNestedErrs=true

--numberFormat=[pattern]

Format numbers using a DecimalFormat pattern.

Usage: beeline --numberFormat="#,###,##0.00"

--force=[true/false]

Continue running script even after errors (true) or do not continue (false). Default is false.

Usage: beeline--force=true

--maxWidth=MAXWIDTH

The maximum width to display before truncating data, in characters, when outputformat is table. Default is to query the terminal for current width, then fall back to 80.

Usage: beeline --maxWidth=150

--maxColumnWidth=MAXCOLWIDTH

The maximum column width, in characters, when outputformat is table. Default is 50 in Hive version 2.2.0+ (see HIVE-14135) or 15 in earlier versions.

Usage: beeline --maxColumnWidth=25

--silent=[true/false]

Reduce the amount of informational messages displayed (true) or not (false). It also stops displaying the log messages for the query from HiveServer2 (Hive 0.14 and later) and the HiveQL commands (Hive 1.2.0 and later). Default is false.

Usage: beeline --silent=true

--autosave=[true/false]

Automatically save preferences (true) or do not autosave (false). Default is false.

Usage: beeline --autosave=true

--outputformat=[table/vertical/csv/tsv/dsv/csv2/tsv2]

Format mode for result display. Default is table. See Separated-Value Output Formats below for description of recommended sv options.

Usage: beeline --outputformat=tsv

Version: dsv/csv2/tsv2 added in 0.14.0 (HIVE-8615)

--truncateTable=[true/false]

If true, truncates table column in the console when it exceeds console length.

Version: 0.14.0 (HIVE-6928)

--delimiterForDSV= DELIMITER

The delimiter for delimiter-separated values output format. Default is '|' character.

Version: 0.14.0 (HIVE-7390)

--isolation=LEVEL

Set the transaction isolation level to TRANSACTION_READ_COMMITTED
or TRANSACTION_SERIALIZABLE.
See the "Field Detail" section in the Java Connection documentation.

Usage: beeline --isolation=TRANSACTION_SERIALIZABLE

--nullemptystring=[true/false]

Use historic behavior of printing null as empty string (true) or use current behavior of printing null as NULL (false). Default is false.

Usage: beeline --nullemptystring=false

Version: 0.13.0 (HIVE-4485)

--incremental=[true/false]

Defaults to false. When set to false, the entire result set is fetched and buffered before being displayed, yielding optimal display column sizing. When set to true, result rows are displayed immediately as they are fetched, yielding lower latency and memory usage at the price of extra display column padding. Setting --incremental=true is recommended if you encounter an OutOfMemory on the client side (due to the fetched result set size being large).

--help

Display a usage message.

Usage: beeline --help

...

Output

...

Starting with Hive 0.14, there are improved SV output formats available, namely DSV, CSV2 and TSV2.  These conform better to standard CSV convention, which adds quotes around a cell value only if it contains special characters (such as the delimiter character or a quote character) or spans multiple lines.  These three formats differ only with the delimiter between cells, which is comma for CSV2, tab for TSV2, and configurable for DSV (delimiterForDSV property).

...

formats

In BeeLine, the result can be displayed in different formats. The format mode can be set with the outputformat option.
The following output formats are supported:

table

The result is displayed in a table. A row of the result corresponds to a row in the table and the values in one row are displayed in separate columns in the table.
This is the default format mode.

Expand
titleExample

 Result of the query select id, value, comment from test_table

No Format
+-----+----------+-----------------------------------------------+
| id  |  value   |                    comment                    |
+-----+----------+-----------------------------------------------+
| 1   | Value1   | Value without quote and delimiter             |
| 2   | Value 2  | Value without quote and delimiter with space  |
| 3   | Value,3  | Value contains comma                          |
| 4   | Value|4  | Value contains pipe character                 |
| 5   | Value&5  | Value contains and character                  |
| 6   | Value'6  | Value contains single quote                   |
| 7   | Value"7  | Value contains double quote                   |
+-----+----------+-----------------------------------------------+

vertical

Each row of the result is displayed in a block of key-value format, where the keys are the name of the columns. The blocks are separated by an empty line.

Expand
titleExample

 Result of the query select id, value, comment from test_table

No Format
id       1
value    Value1
comment  Value without quote and delimiter
id       2
value    Value 2
comment  Value without quote and delimiter with space
id       3
value    Value,3
comment  Value contains comma
id       4
value    Value|4
comment  Value contains pipe character
id       5
value    Value&5
comment  Value contains and character
id       6
value    Value'6
comment  Value contains single quote
id       7
value    Value"7
comment  Value contains double quote

xmlattr

The result is displayed in an xml format where each row is a "result" element in the xml.
The values of a row are displayed as attributes on the "result" element. The name of the attributes are the name of the columns.

Expand
titleExample

 Result of the query select id, value, comment from test_table

No Format
<resultset>
  <result id="1" value="Value1" comment="Value without quote and delimiter"/>
  <result id="2" value="Value 2" comment="Value without quote and delimiter with space"/>
  <result id="3" value="Value,3" comment="Value contains comma"/>
  <result id="4" value="Value|4" comment="Value contains pipe character"/>
  <result id="5" value="Value&5" comment="Value contains and character"/>
  <result id="6" value="Value'6" comment="Value contains single quote"/>
  <result id="7" value="Value&quot;7" comment="Value contains double quote"/>
</resultset>

xmlelements

The result is displayed in an xml format where each row is a "result" element in the xml. The values of a row are displayed as child elements of the result element.

Expand
titleExample

 Result of the query select id, value, comment from test_table

No Format
<resultset>
  <result>
    <id>1</id>
    <value>Value1</value>
    <comment>Value without quote and delimiter</comment>
  </result>
  <result>
    <id>2</id>
    <value>Value 2</value>
    <comment>Value without quote and delimiter with space</comment>
  </result>
  <result>
    <id>3</id>
    <value>Value,3</value>
    <comment>Value contains comma</comment>
  </result>
  <result>
    <id>4</id>
    <value>Value|4</value>
    <comment>Value contains pipe character</comment>
  </result>
  <result>
    <id>5</id>
    <value>Value&5</value>
    <comment>Value contains and character</comment>
  </result>
  <result>
    <id>6</id>
    <value>Value'6</value>
    <comment>Value contains single quote</comment>
  </result>
  <result>
    <id>7</id>
    <value>Value&quot;7</value>
    <comment>Value contains double quote</comment>
  </result>
</resultset>

Separated-Value Output Format

The values of a row are separated by different delimiters.
There are five separated-value output formats available: csv, tsv, csv2, tsv2 and dsv.

csv2, tsv2, dsv

Starting with Hive 0.14, there are improved SV output formats available, namely dsv, csv2 and tsv2.
These three formats differ only with the delimiter between cells, which is comma for csv2, tab for tsv2, and configurable for dsv.

For the dsv format, the delimiter can be set with the delimiterForDSV option. The default delimiter is '|'.
Please be aware that only single character delimiters are supported.

Expand
titleExample

 Result of the query select id, value, comment from test_table

csv2

No Format
id,value,comment
1,Value1,Value without quote and delimiter
2,Value 2,Value without quote and delimiter with space
3,Value,3,Value contains comma
4,Value|4,Value contains pipe character
5,Value&5,Value contains and character
6,Value'6,Value contains single quote
7,Value"7,Value contains double quote

 

tsv2

No Format
id	value	comment
1	Value1	Value without quote and delimiter
2	Value 2	Value without quote and delimiter with space
3	Value,3	Value contains comma
4	Value|4	Value contains pipe character
5	Value&5	Value contains and character
6	Value'6	Value contains single quote
7	Value"7	Value contains double quote

 

dsv (the delimiter is |)

No Format
id|value|comment
1|Value1|Value without quote and delimiter
2|Value 2|Value without quote and delimiter with space
3|Value,3|Value contains comma
4|Value|4|Value contains pipe character
5|Value&5|Value contains and character
6|Value'6|Value contains single quote
7|Value"7|Value contains double quote

Quoting

If quoting is not disabled, double quotes are added around a value if it contains special characters (such as the delimiter or double quote character) or spans multiple lines.
Embedded double quotes are escaped with a preceding double quote.

The quoting can be disabled by setting the disable.quoting.for.sv system variable to true.
If the quoting is disabled, no double quotes are added around the values (even if they contains special characters) and the embedded double quotes are not escaped.
By default, the quoting is disabled.

Expand
titleExample

 Result of the query select id, value, comment from test_table

csv2, quoting is enabled

No Format
id,value,comment
1,"Value,1",Value contains comma
2,"Value""2",Value contains double quote
3,Value'3,Value contains single quote

 

csv2, quoting is disabled

No Format
id,value,comment
1,Value,1,Value contains comma
2,Value"2,Value contains double quote
3,Value'3,Value contains single quote
csv, tsv

These two formats differ only with the delimiter between values, which is comma for csv and tab for tsv.
The values are always surrounded with single quote characters, even if the quoting is disabled by the disable.quoting.for.sv system variable.
These output formats don't escape the embedded single quotes.
Please be aware that these output formats are deprecated and only maintained for backward compatibility.

Expand
titleExample

 Result of the query select id, value, comment from test_table

csv

No Format
'id','value','comment'
'1','Value1','Value without quote and delimiter'
'2','Value 2','Value without quote and delimiter with space'
'3','Value,3','Value contains comma'
'4','Value|4','Value contains pipe character'
'5','Value&5','Value contains and character'
'6','Value'6','Value contains single quote'
'7','Value"7','Value contains double quote'

 

tsv

No Format
'id'	'value'	'comment'
'1'	'Value1'	'Value without quote and delimiter'
'2'	'Value 2'	'Value without quote and delimiter with space'
'3'	'Value,3'	'Value contains comma'
'4'	'Value|4'	'Value contains pipe character'
'5'	'Value&5'	'Value contains and character'
'6'	'Value'6'	'Value contains single quote'
'7'	'Value"7'	'Value contains double quote'

HiveServer2 Logging

Starting with Hive 0.14.0, HiveServer2 operation logs are available for Beeline clients. These parameters configure logging:

...