hive 之 Fetch Task功能描述應用

Fetch Task功能

一個簡單的查詢語句,是指一個沒有函數、排序等功能的語句,當開啓一個Fetch
Task功能,就執行一個簡單的查詢語句不會生成MapRreduce作業,而是直接使用FetchTask,從hdfs文件系統中進行查詢輸出數據,從而提高效率。

3種配置方式
1、在hive提示符

set hive.fetch.task.conversion=more;

2、啓動hive時,加入參數

 hive --hiveconf hive.fetch.tas.conversion=more

3、修改 hive-site.xml文件 ,加入屬性,保存退出。

<property>
    <name>hive.fetch.task.conversion</name>
    <value>more</value>
</property>

測試語句

可先行建表emp

hive>desc emp;

查詢所有信息

select * from emp;

查詢 員工號 姓名 月薪

select empno,ename,sal from emp;

查詢 員工號 姓名 月薪 年薪 支持算術表達式

select empno,ename,sal,sal*12 from emp;

查詢 員工號 姓名 月薪 年薪 獎金 年收入

select empno,ename,sal,sal*12,comm,sal*12+comm from emp;

nvl函數將null 轉化爲 數字 0

select empno,ename,sal,sal*12,comm,sal*12+nvl(comm,0) from emp; 

查詢 獎金爲空的員工

select * from emp where comm=null; 錯誤的
select * from emp where comm is null;

使用distinct來去掉重複的記錄

select deptno from emp;
select distinct depton from emp;
select distinct deptno,job from emp;

原文鏈接:https://blog.csdn.net/lepton126/article/details/80281528

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章