我想通过运行蜂巢脚本sample.hql去取年= 2016的记录。
use octdb;
select * from '${hiveconf:table}' where year = '${hiveconf:year}';
[[email protected] ~]$ hive -hiveconf table='employee', year=2016 -f sample.hql
但我得到错误NoViableAltException(307 @ []).......
我想通过运行蜂巢脚本sample.hql去取年= 2016的记录。
use octdb;
select * from '${hiveconf:table}' where year = '${hiveconf:year}';
[[email protected] ~]$ hive -hiveconf table='employee', year=2016 -f sample.hql
但我得到错误NoViableAltException(307 @ []).......
您需要使用--hiveconf
选项两次:
hive --hiveconf table=employee --hiveconf year=2016 -f sample.hql
这样做[R & D找到了正确的答案,$ {hiveconf:table}应该在不带''的脚本中定义。 sample.hql: -
use ${hiveconf:database};
select * from ${hiveconf:table} where year = ${hiveconf:year};
运行sample.hql
[[email protected] shell]$ hive -hiveconf database=octdb -hiveconf table=employee -hiveconf year=2016 -f sample.hql
日志文件中使用配置初始化:/etc/hive/conf.dist/hive-log4j.properties OK
采取Time taken: 1.484 seconds
OK
1 A 2016
2 B 2016
4 D 2016
时间:4.423秒,抓取时间:3行(多个)
感谢您的搜索解决方案ñ但我仍然得到相同的错误。 –
错误: NoViableAltException(307 @ []) FAILED:ParseException的线2:14不能识别邻近 '输入' 雇员 '' '其中' '年' 中加入源 WARN:该方法类org.apache.commons。 logging.impl.SLF4JLogFactory#release()被调用。 警告:请参阅http://www.slf4j.org/codes.html#release以获取解释。 –
“雇员”后面仍然使用逗号;去掉它。没有名为'employee'的表。 – chepner