hive的sql語句小節
阿新 • • 發佈:2019-02-13
insert number span 公司 left mysql ase 技術 sub 20180615:
get product_city_staypoint_data.zip
愛癡 2018/6/25 15:25:32
select g.accs_nbr,
Hive是基於Hadoop的一個數據倉庫工具,是一種邏輯上的數據庫,依賴hdfs文件系統;它把實際的數據文件映射為一張數據庫表來作為元數據來管理hdfs上的數據。Hive存在的意義並非數據存儲,而是被用來處理數據的,它計算的實質是用sql調用了底層的mapreduce。因為hive的sql的學習成本比較低,幾乎和mysql這些數據庫近似,所以使用極其廣泛。很多公司使用hive幾乎都能夠撐起整個項目。
cd bigdata-Guanxiyingxiao/Guanxiyingxiao/2018
get Guanxiyingxiao.zip
cd dawen.chi/product_city_staypoint_data/2018
cd ctyun-product-tianyuan/city-plan-paltform/2018
get city-plan-paltform.zip
清空hive表:
insert overwrite table dal_bdcsc_bad_black_list_m select * from t_table1 where 1=0;
md5加密:
https://md5jiami.51240.com/
愛癡 2018/6/25 15:25:21
yarn queue -status pro2
你用這個看看隊列資源
秦文傑 2018/6/25 15:26:02
愛癡 2018/6/25 15:26:06
hadoop job -list | 隊列名 用這個命令看看你現在的隊列上面有幾個任務
15:26:35
愛癡 2018/6/25 15:26:35
hadoop job -list | grep test1
秦文傑 2018/6/25 15:27:05
INSERT OVERWRITE table csqinwj.dal_bdcsc_bad_black_list_m PARTITION(PROV_ID, MONTH_ID)
g.cert_nbr,
g.cust_name,
g.prov_id,
201705 MONTH_ID
from (select accs_nbr,
cert_nbr,
cust_name,
uninstall_date,
prov_id
from CSQINWJ.DWI_SEV_USER_MAIN_INFO_PRO_MSK_M
where month_id=‘201804‘ and cert_type=‘1‘)g --證件類型為身份證
INNER join
(select MD5(t.accs_nbr) accs_nbr,
substr(t.biz_event_time,1,8) time
from(select b.accs_nbr,
b.biz_event_time,
max(case when a.rn=b.rn+1 then a.order_type end) type_a,
max(case when a.rn=b.rn+2 then a.order_type end) type_b
from (select a.accs_nbr,
a.user_status,
a.order_type,
a.biz_event_time,
row_number() over(partition by a.accs_nbr order by a.biz_event_time desc) as rn
from (select accs_nbr,
user_status,
order_type,
biz_event_time,
row_number() over(partition by accs_nbr order by biz_event_time desc) as rn
from csqinwj.dwi_sev_user_vsop_decode_d_mid where MONTH_ID<=201705) a
left join (select accs_nbr,
user_status,
order_type,
biz_event_time,
row_number() over(partition by accs_nbr order by biz_event_time desc) as rn
from csqinwj.dwi_sev_user_vsop_decode_d_mid where MONTH_ID<=201705) b
on a.accs_nbr = b.accs_nbr and a.rn = b.rn + 1
where a.order_type <> nvl(b.order_type, ‘0‘)) a
inner join (select * from (select a.accs_nbr,
a.user_status,
a.order_type,
a.biz_event_time,
row_number() over(partition by a.accs_nbr order by a.biz_event_time desc) as rn
from (select accs_nbr,
user_status,
order_type,
biz_event_time,
row_number() over(partition by accs_nbr order by biz_event_time desc) as rn
from csqinwj.dwi_sev_user_vsop_decode_d_mid where MONTH_ID<=201705) a
left join (select accs_nbr,
user_status,
order_type,
biz_event_time,
row_number() over(partition by accs_nbr order by biz_event_time desc) as rn
from csqinwj.dwi_sev_user_vsop_decode_d_mid where MONTH_ID<=201705) b
on a.accs_nbr = b.accs_nbr
and a.rn = b.rn + 1
where a.order_type <> nvl(b.order_type, ‘0‘))c where c.order_type=‘300‘ --銷戶/拆機
) b
on a.accs_nbr=b.accs_nbr
group by b.accs_nbr,b.biz_event_time,b.order_type)t
where t.type_a=‘48‘ or --欠費雙停
(t.type_a=‘301‘ --預約銷戶
and t.type_b=‘48‘)) h
where g.accs_nbr=h.accs_nbr and substr(g.uninstall_date,1,8)=h.time;
hive的sql語句小節