Versions Compared

Key

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

...

Expand
titleExample

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

No Format
+-----+---------+-+----------------+
| id  |  value  |     comment     |
+-----+---------+-----------------+
| 1 id  |  valueValue1   | Test comment 1  |
| 2   | Value2         | Test comment 2  |
| 3   | Value3  | Test comment 3       |
+-----+----------+-----------------------------------------------+
| 1   | Value1   | Value without quote and delimiter  +

vertical

Each row of the result is displayed in a block of key-value format, where the keys are the name of the columns.

Expand
titleExample

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

No Format
id       1
value    Value1
comment  Test comment 1

id       2
value    |Value2
|comment 2 Test  |comment Value 2


id  | Value without quote and delimiter3
value with space  |Value3
|comment 3 Test  | 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.

comment 3

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="Test comment 1"/>
  <result id="2" value="Value2" comment="Test comment 2"/>
  <result id="3" value="Value3" comment="Test comment 3"/>
</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>Test comment 1</comment>
  </result>
  <result>
    <id>2</id>
    <value>Value2</value>
    <comment>Test comment 2</comment>
  </result>
  <result>
    <id>3</id>
    <value>Value3</value>
    <comment>Test comment 3</comment>
  </result>
</resultset>

Separated-Value Output Formats

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 supportedThe 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,Value1,Test comment 1
2,Value2,Test comment 2
3,Value3,Test comment 3
 

tsv2

No Format
id	value	comment
1	Value1	Test comment 1
2	Value2	Test comment 2
3	Value3	Test comment 3

dsv (the delimiter is |)

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
|Value1|Test comment 1
2|Value2|Test comment 2
3|Value3|Test comment 3

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

csvcsv2, quoting is enabled

No Format
'id','value','comment'
'1','Value1',',"Value,1",Value without quote and delimiter'
'2','Value 2','Value without quote and delimiter with space'
'3','Value,3','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'
'4'2,'Value|4'"2,'Value contains pipedouble character'
'5','Value&5','quote
3,Value'3,Value contains and character'
'6','Value'6','Value contains single quote'
'7','Value"7','Value contains double quote'

 

tsv

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'	,'ValueTest without quote and delimitercomment 1'
'2'	,'Value 2Value2'	,'ValueTest without quote and delimiter with spacecomment 2'
'3','	Value3'Value,3'	'ValueTest containscomment comma'
'43'

tsv

No Format
'id'	'Value|4value'	'Value contains pipe charactercomment'
'51'	'Value&5Value1'	'ValueTest containscomment and character1'
'62'	'ValueValue2'6'	'ValueTest containscomment single quote2'
'73'	'Value"7Value3'	'ValueTest containscomment double quote3'

HiveServer2 Logging

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

...