hive -e "show tables"提示cannot recognize input near 'show' '' '' in ddl statement

一、前言

      項目需要,需要知道hive的支持的最大併發用戶數目是否滿足需求,因此,寫了個小程序測試 ,方式是java調用命令行程序的方式進行。

即:

 Process executor = Runtime.getRuntime().exec(command,env);

但是這樣做面臨一個問題,就是在命令行輸入hive -e "show tables"一切正常,如下所示。

[niy@niy-computer /]$ hive -e "show tables"

Logging initialized using configuration in file:/home/niy/workspace1/hive/trunk/conf/hive-log4j.properties
Hive history file=/tmp/niy/hive_job_log_niy_201305201234_366682237.txt
OK
alter2
niytab
part_nowhitelist_test
part_whitelist_test
poke
poke1
poke3
raw
src_rc_concatenate_test
table1
table3
test_table
test_table_like
xx
Time taken: 6.217 seconds, Fetched: 14 row(s)
而採用java程序調用 命令行的方式 上面的command 的參數就是hive -e "show tables",則運行失敗,提示


 

二 解決方案


提示 cannot recognize input near 'show' '<EOF>' '<EOF>' in ddl statement,即告知 show 以後的語句“ tables”沒有讀取成功,換成"show databases"可以發現錯誤依舊。

調試發現程序 在運行到

Process executor = Runtime.getRuntime().exec(command,env);

command 的值是hive -e "show tables",即交給hive 時是準確無誤的,可以斷定解析出錯是hive 本身的問題。

由於時間有限,暫給出解決方案,採用hive -f 來避開該問題,至於這問題的正面解決方案以後有時間 再處理,初步感覺可能是hive 的bug。

首先將hive ql語句 寫入 文件/home/niy/tmp.ql (.ql後綴)

採用hive -v -f  /home/niy/tmp.ql

搞定。

三 總結


問題的解決有時不是兵來將擋,水來土埋的正面迴應,也可以是採用迂迴戰術。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章