【问题标题】:Avoid printing table name in column name while using beeline使用直线时避免在列名中打印表名
【发布时间】:2017-03-30 08:50:12
【问题描述】:

在直线中使用 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  |
+------+-------+---------+--------------+--+
+------+-------+---------+--------------+--+

问题

我希望避免在每次运行 select 查询时输入 AS 并作为默认行为返回列名中没有表名的结果。

【问题讨论】:

    标签: sql select hive beeline


    【解决方案1】:

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

    Configuration Properties

    演示

    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
    

    【讨论】:

      猜你喜欢
      • 2014-10-31
      • 1970-01-01
      • 2016-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-27
      • 1970-01-01
      • 2021-08-25
      相关资源
      最近更新 更多