Avoid printing table name in column name while using beeline

Konrad picture Konrad · Mar 30, 2017 · Viewed 7.6k times · Source

While using hive in beeline an using simple select query I would like to return table without table name in column name as a default.

Example

Data

On example of a simple table (TutorialsPoint):

CREATE TABLE IF NOT EXISTS employee ( eid int, name String,
salary String, destination String)
COMMENT 'Employee details'
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\n'
STORED AS TEXTFILE;

The SELECT query returns:

SELECT * FROM employee;
+---------------+----------------+------------------+-----------------------+--+
| employee.eid  | employee.name  | employee.salary  | employee.destination  |
+---------------+----------------+------------------+-----------------------+--+
+---------------+----------------+------------------+-----------------------+--+

Desired results

The desired results are achieved with use of AS:

SELECT eid AS eid, name AS name, salary AS salary, 
       destination AS destination FROM employee;

+------+-------+---------+--------------+--+
| eid  | name  | salary  | destination  |
+------+-------+---------+--------------+--+
+------+-------+---------+--------------+--+

Problem

I would like to avoid typing AS each time I run select query and return results without table names in column names as default behaviour.

Answer

David דודו Markovitz picture David דודו Markovitz · Mar 30, 2017

set hive.resultset.use.unique.column.names=false

Configuration Properties

Demo

hive> create table t (i int,j int,k int);
hive> select * from t;

t.i t.j t.k

hive> set hive.resultset.use.unique.column.names=false;
hive> select * from t;

i   j   k