Support Questions

Find answers, ask questions, and share your expertise

Beeline select query

avatar

I am trying to switch to Beeline from hive, but I have one issue.

Hive :

Query : select * from table;

Output : The output is in readable format i.e we can scroll down to see complete data on my screen(terminal).

Beeline : Query : select * from table;

Output : The output is not in readable format i.e we cannot scroll down to see complete data. All columns are mixed up.

Work Around : I tried setting --maxWidth=100 it worked for one table with 10 columns. But still the output is not properly readable. I have to change the value of maxWidth for different tables as different tables have different number of columns.

So, is there any way to set some default value so that the data becomes understandable using beeline?

1 ACCEPTED SOLUTION

avatar
Master Guru

Hey @Pooja Chawda

Hope are doing well! 🙂

Can you try below thing?

$beeline -u jdbc:hive2://<server-ip>:10000/databaseName  -n <your-id> -p <your-password> --outputformat=csv -f input_query.sql > results.out

Or you can use below parameters:

--outputformat=csv

--headerInterval=400

--showHeader=false

--maxColumnWidth=20

Hope this helps!

View solution in original post

4 REPLIES 4

avatar
Master Guru

Hey @Pooja Chawda

Hope are doing well! 🙂

Can you try below thing?

$beeline -u jdbc:hive2://<server-ip>:10000/databaseName  -n <your-id> -p <your-password> --outputformat=csv -f input_query.sql > results.out

Or you can use below parameters:

--outputformat=csv

--headerInterval=400

--showHeader=false

--maxColumnWidth=20

Hope this helps!

avatar

@Kuldeep Kulkarni thanks it worked for me.

avatar
Master Guru

Thank you @Pooja Chawda

avatar
Rising Star

Due to HIVE_8615, it is advised to start using csv2/tsv2 for Beeline output formatting as csv/tsv are deprecated as of Hive 0.14.

More details can be on the Apache Hiveserver2 Client wiki:

"Separated-Value Output Formats 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).

CSV and TSV output formats are maintained for backward compatibility, but beware as they add additional single-quote characters around all cell values contrary to this convention."