Hive腳本中切勿使用/**/注釋


Hive腳本中切勿使用/**/注釋

 

Hive腳本的注釋目前好像只有 -- ,我之前在做初版數據的時候 使用NotePad++ 習慣性的有時候注釋會寫成 /**/ ,然后就引發了問題

腳本上傳到hue,加入調度,調度正常執行 不報錯,但是應該有的數據卻為空!!! 奇了怪了.... (反復執行了好多遍,都沒有數據,腳本都沒有問題呀  一段一段copy執行的時候都正常的)

再仔細看看 ,原因問題出在注釋上,在hive腳本里面我不小心留了兩行注釋 格式為 /* 注釋內容 */ 的內容

造成的結果:  /*注釋內容*/ 前面的腳本內容正常執行,/* 注釋內容*/ 后面的腳本內容統統沒有執行,所以很多該有的數據都為空了....

 

錯誤腳本內容示例:

insert.hql

use bgda_hw_stg;
set hive.auto.convert.join=false;

drop table testdata ;
create table testdata(
createUser string
,createTime string
,updateUser string
,updateTime string
) row format delimited fields terminated by '\001';

insert overwrite table testdata
select 
,'小仙女' as createUser
,cast(from_unixtime(unix_timestamp(),'yyyy-MM-dd HH:mm:ss') as string)as createTime 
,'小天使' as updateUser
,'' as updateTime
;

/* 將T+1數據插入testdata_bak表中 testdata_bak表在初始化的時候已經創建,目前已存在於bgda_hw_stg庫中*/
insert into testdata_bak select * from testdata;

  

以上腳本信息中:由於注釋方式

/* 將T+1數據插入testdata_bak表中 testdata_bak表在初始化的時候已經創建,目前已存在於bgda_hw_stg庫中*/

 導致 insert into testdata_bak select * from testdata; 這段hql 不會被執行,但是整個調度也不會報錯!!!

所以這個一定要注意一下哦,注釋方式一定要正確的寫,如果發現腳本執行沒有報錯 但是該有的數據沒有 可以查看以下腳本中是否存在不規則的注釋...(不過大部分數據錯處應該是及腳本邏輯問題哈哈哈)

 

正確示例:

insert.hql

use bgda_hw_stg;
set hive.auto.convert.join=false;

drop table testdata ;
create table testdata(
createUser string
,createTime string
,updateUser string
,updateTime string
) row format delimited fields terminated by '\001';


insert overwrite table testdata
select 
,'小仙女' as createUser
,cast(from_unixtime(unix_timestamp(),'yyyy-MM-dd HH:mm:ss') as string)as createTime 
,'小天使' as updateUser
,'' as updateTime
;

-- 將T+1數據插入testdata_bak表中 testdata_bak表在初始化的時候已經創建,目前已存在於bgda_hw_stg庫中
insert into testdata_bak
select * from testdata;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM