设置成功,我们来看一下效果
hive> select * from tmp_mult_partition limit 5; OK tmp_mult_partition.id tmp_mult_partition.title tmp_mult_partition.a tmp_mult_partition.b tmp_mult_partition.c 1 a1 a2 b1 c1 2 a2 a2 b1 c1 3 a3 a2 b1 c1 4 a4 a2 b1 c1 5 a5 a2 b1 c1 Time taken: 0.243 seconds, Fetched: 5 row(s)** 可以看到hive查询时已经显示字段名,打印头信息 ** 但带有表名,看起来不是很直观,表名主要是为了区别字段的唯一性,我们需要隐藏表名,可以通过设置hive.resultset.use.unique.column.names为false来实现
hive> -- 显示字段 > set hive.cli.print.header=true; hive> select * from tmp_mult_partition limit 5; OK tmp_mult_partition.id tmp_mult_partition.title tmp_mult_partition.a tmp_mult_partition.b tmp_mult_partition.c 1 a1 a2 b1 c1 2 a2 a2 b1 c1 3 a3 a2 b1 c1 4 a4 a2 b1 c1 5 a5 a2 b1 c1 Time taken: 0.243 seconds, Fetched: 5 row(s) hive> -- 只显示字段名 > set hive.resultset.use.unique.column.names=false; hive> select * from tmp_mult_partition limit 5; OK id title a b c 1 a1 a2 b1 c1 2 a2 a2 b1 c1 3 a3 a2 b1 c1 4 a4 a2 b1 c1 5 a5 a2 b1 c1 Time taken: 0.283 seconds, Fetched: 5 row(s)非常棒,达到我们的预期,仅显示字段名称
方案二、所有集群客户端永久显示(cdh界面化配置) 通过Cloudera Management 配置hive-site.xml,完成集群配置调整 查看是否配置更新成功: 方式1.通过界面查看:方式2.通过配置查看:
[hdfs@hbase-3 conf]$ cat hive-site.xml ... <property> <name>hive.cli.print.header</name> <value>true</value> </property> <property> <name>hive.resultset.use.unique.column.names</name> <value>false</value> </property> </configuration>效果验证:
hive> select * from tmp_mult_partition limit 5; OK id title a b c 1 a1 a2 b1 c1 2 a2 a2 b1 c1 3 a3 a2 b1 c1 4 a4 a2 b1 c1 5 a5 a2 b1 c1 Time taken: 0.283 seconds, Fetched: 5 row(s) 方案三、所有集群客户端永久显示(配置文件调整)修改 hive-site.xml文件
<property> <name>hive.cli.print.header</name> <value>true</value> </property> <property> <name>hive.resultset.use.unique.column.names</name> <value>false</value> </property>重启服务后