本篇文章給大家分享的是有關(guān)如何在shell中循環(huán)調(diào)用hive sql 腳本,小編覺得挺實(shí)用的,因此分享給大家學(xué)習(xí),希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。
腳本tt.sh的內(nèi)容如下:
#!/bin/bash params=$1 for param in $params do echo $param done
運(yùn)行方式為:sh tt.sh "1 2 3 4 5"
輸出為:
1 2 3 4 5
所以參考上面的命令,可以把hql的腳本寫為如下方式,就可以循環(huán)執(zhí)行sql:
功能:查找字符串 comments 中的param第一次出現(xiàn)的位置 ,返回的是位置數(shù)字
#!/bin/bash params=$1 for param in $params do hive -e "insert overwrite local directory '/tmp/$param' row format delimited fields terminated by '\t' select locate('$param',comments) as position from tb_a;" done
功能:查找評(píng)論中出現(xiàn)關(guān)鍵字的內(nèi)容,沒有關(guān)鍵詞的內(nèi)容過濾掉
#!/bin/bash params=$1 for param in $params do hive -e "insert overwrite local directory '/tmp/$param' row format delimited fields terminated by '\t' select position from (select locate('$param',comments) as position from tb_a where position != '0') a where a.position !='0' ;" done
以上就是如何在shell中循環(huán)調(diào)用hive sql 腳本,小編相信有部分知識(shí)點(diǎn)可能是我們?nèi)粘9ぷ鲿?huì)見到或用到的。希望你能通過這篇文章學(xué)到更多知識(shí)。更多詳情敬請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
網(wǎng)站題目:如何在shell中循環(huán)調(diào)用hivesql腳本-創(chuàng)新互聯(lián)
標(biāo)題鏈接:http://vcdvsql.cn/article46/eihhg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供虛擬主機(jī)、網(wǎng)站改版、微信小程序、Google、品牌網(wǎng)站設(shè)計(jì)、網(wǎng)站排名
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容