如何在hive脚本中传递多个参数

Riy*_*han 3 shell hive hiveql

员工: 表数据

我想通过运行hive脚本sample.hql来获取year = 2016的记录.

use octdb;
select * from '${hiveconf:table}' where year = '${hiveconf:year}';

[cloudera@quickstart ~]$ hive -hiveconf table='employee', year=2016 -f sample.hql
Run Code Online (Sandbox Code Playgroud)

但我收到错误NoViableAltException(307 @ []).......

che*_*ner 8

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

hive --hiveconf table=employee --hiveconf year=2016 -f sample.hql
Run Code Online (Sandbox Code Playgroud)