使用beeline时避免在列名中打印表名

ivqmmu1c  于 2021-06-26  发布在  Hive
关注(0)|答案(1)|浏览(414)

当使用Hive在直线和使用简单 select 查询我想返回列名称中没有表名的表作为默认值。

示例

数据

在简单表(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;

这个 SELECT 查询返回:

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

期望的结果

通过使用 AS :

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

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

问题

我想避免打字 AS 每次我跑 select 作为默认行为,查询并返回列名中没有表名的结果。

cnjp1d6j

cnjp1d6j1#

set hive.resultset.use.unique.column.names=false 配置属性

演示

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

相关问题