2017-10-09 64 views

回答

1

您需要使用--hiveconf选项两次:

hive --hiveconf table=employee --hiveconf year=2016 -f sample.hql 
+0

感谢您的搜索解决方案ñ但我仍然得到相同的错误。 –

+0

错误: NoViableAltException(307 @ []) FAILED:ParseException的线2:14不能识别邻近 '输入' 雇员 '' '其中' '年' 中加入源 WARN:该方法类org.apache.commons。 logging.impl.SLF4JLogFactory#release()被调用。 警告:请参阅http://www.slf4j.org/codes.html#release以获取解释。 –

+0

“雇员”后面仍然使用逗号;去掉它。没有名为'employee'的表。 – chepner

0

这样做[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行(多个)