您的位置:首页 > 其它

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

2013-06-05 23:44 405 查看


一、前言

项目需要,需要知道hive的支持的最大并发用户数目是否满足需求,因此,写了个小程序测试 ,方式是java调用命令行程序的方式进行。

即:

[java] view
plaincopy

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

但是这样做面临一个问题,就是在命令行输入hive -e "show tables"一切正常,如下所示。

[plain] view
plaincopy

[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"可以发现错误依旧。

调试发现程序 在运行到

[java] view
plaincopy

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

搞定。


三 总结

问题的解决有时不是兵来将挡,水来土埋的正面回应,也可以是采用迂回战术。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐