Pass environment variables to Hive Transform or MapReduce

房东的猫 提交于 2019-12-11 00:07:45

问题


I am trying to pass a custom environment variable to an executable (my-mapper.script in the example below) used in a Hive Transform eg:

SELECT
   TRANSFORM(x, y, z)
   USING 'my-mapper.script'
FROM
(
   SELECT
      x, y, z
   FROM
      table
)

I know in Hadoop streaming this can be achieved using

-cmdenv EXAMPLE_DIR=/home/example/dictionaries/

But I do not know how to do this in a Hive Transform/MapReduce.

Any ideas?


回答1:


You can wrap your script with a simple 2 line bash script to setup the environment. e.g

#!/bin/sh
export FOO=boo
my-mapper.script

And then use this script in the query

USING 'wrapper.sh'

my-mapper.script will see FOO (with value "boo") in the environment.




回答2:


Are you looking for something like this?

% hive -hiveconf CURRENT_DATE='2012-09-16' -f test.hql


来源:https://stackoverflow.com/questions/16339123/pass-environment-variables-to-hive-transform-or-mapreduce

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!