標籤:
錯誤一:
Hive的where後不能用欄位的別名,
錯誤二:
hive的groupby中不能用自己定義函數,否則報錯(用嵌套select取代)
錯誤三:
運行:$ ./hive_game_operationstatis5.sh時,報錯資訊例如以下:
./hive_game_operationstatis5.sh:line 11: [: missing `]'./hive_game_operationstatis5.sh:line 17: /tmp/statis_activitysourcestatis20141014/statis_activitysourcestatis120141014.txt:No such file or directory./hive_game_operationstatis5.sh:line 36:/tmp/statis_activitysourcestatis20141014/statis_activitysourcestatis220141014.txt:No such file or directoryERROR 2 (HY000) atline 1: File'/tmp/statis_activitysourcestatis20141014/statis_activitysourcestatis120141014.txt'not found (Errcode: 2)ERROR 2 (HY000) atline 1: File'/tmp/statis_activitysourcestatis20141014/statis_activitysourcestatis220141014.txt'not found (Errcode: 2)
錯誤分析:
因為11行的建立檔案夾代碼沒起作用,所以導致後邊一系列找不到檔案路徑的錯誤。
報錯時的代碼:
if [ ! -d $output]then mkdir -p $outputfi<span style="font-family: Arial, Helvetica, sans-serif;"> </span>
改動後的代碼:
if [ ! -d $output]then mkdir -p $outputfi
看到區別了沒??$output與]之間應該有個空格!
。
錯誤四:date不能識別
運行./hive_game_operationstatis6.sh指令碼時。報錯例如以下:
./hive_game_operationstatis6.sh:line 12: [: /tmp/statis_suspendedwindowstatisdate: binary operator expected./hive_game_operationstatis6.sh:line 21: $output/$file_name1: ambiguous redirect./hive_game_operationstatis6.sh:line 39: $output/$file_name2: ambiguous redirect./hive_game_operationstatis6.sh:line 56: $output/$file_name3: ambiguous redirect./hive_game_operationstatis6.sh:line 73: $output/$file_name4: ambiguous redirect./hive_game_operationstatis6.sh:line 90: $output/$file_name5: ambiguous redirect
分析:
在shell指令碼中我是這樣寫:
output='/tmp/statis_suspendedwindowstatis'$datefile_name1='statis_suspendedwindowstatis1'$date'.txt'
錯誤顯示是指調用時”模糊的重新導向”!
單從錯誤提示上看不出個所以然來。請直接看出錯代碼:
改動之前代碼:
date=’date +%Y%m%d’
改動此bug之後代碼:
date=`date +%Y%m%d`
大家看到哪裡出錯了沒??哈哈,是的,太坑啦!
shell要用鍵盤上1前邊的‘撇’,而不能用雙引號那個‘撇’兒。
。
假設一個變數後是字串的話直接用斷行符號左邊那個’撇‘就能夠,
對於我這個初次接觸shell的人。簡直頭疼到了極點!
希望大家不要犯類似的錯誤。
寫hive sql和shell指令碼時遇到幾個蛋疼的問題!