【问题标题】:Passing parameter in hive is not working在 hive 中传递参数不起作用
【发布时间】:2016-10-03 03:06:01
【问题描述】:

在 hive 中传递参数对我不起作用。我的代码:

hive> set x='test variable';
hive> ${hiveconf:x};

我收到此错误:

失败:解析错误:第 1:0 行无法识别''test variable'' '<EOF>' '<EOF>' 附近的输入

【问题讨论】:

  • 为什么不在执行前使用select ${hiveconf:x};打印出来?

标签: hadoop hive hiveql hadoop-streaming


【解决方案1】:
hive> ${hiveconf:x};

将逐字替换'test variable'。所以你正在执行命令

hive> 'test variable';

这应该会导致错误,因为这不是我在 SQL 中见过的命令。

如果你想输出 x 的值,你只需要这样做

SET x;

如果你想在语句中使用x的值,你可以这样做

SELECT * FROM TABLE tbl WHERE a=${hiveconf:x};

将运行命令

SELECT * FROM TABLE tbl WHERE a='test variable';

【讨论】:

    【解决方案2】:

    试试:

    hive> set x='test variable';
    hive> set;
    

    您将在许多变量的值中看到x 变量的值。

    【讨论】:

      猜你喜欢
      • 2016-09-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-06
      • 1970-01-01
      • 2021-09-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多