【问题标题】:Passing arguments to hive query将参数传递给配置单元查询
【发布时间】:2017-01-19 14:16:08
【问题描述】:

我正在尝试通过以下方式传递命令行参数,但它不起作用。谁能帮我解决我在这里做错的事情!

hive -f test2.hql -hiveconf partition=20170117 -hiveconf -hiveconf datepartition=20170120 

【问题讨论】:

    标签: hadoop mapreduce hive


    【解决方案1】:

    在查询文件之前传递你的参数,

    hive --hiveconf partition='20170117' --hiveconf datepartition='20170120' -f test2.hql 
    

    像这样在test2.hql 的查询中使用它们,

    ${hiveconf:partition}
    

    示例:

    select * from tablename where partition=${hiveconf:partition} and date=${hiveconf:datepartition}
    

    【讨论】:

      【解决方案2】:

      一些替代方案:

      1) 如果使用 hive 命令行,您可以详细说明整个 sql 命令并执行如下:

      hive -e <command>
      

      并将参数显式为文字。

      2)如果使用beeline(首选hive),只需将其附加到命令行:

      --hivevar myparam='myvalue'
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-09-27
        • 2014-08-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-01-26
        相关资源
        最近更新 更多