将环境变量传递给Hive Transform或MapReduce [英] Pass environment variables to Hive Transform or MapReduce
本文介绍了将环境变量传递给Hive Transform或MapReduce的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图将一个自定义环境变量传递给Hive变换
中使用的可执行文件(my-mapper.script,如下例所示):
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
)
我知道在Hadoop流媒体中,可以使用
I know in Hadoop streaming this can be achieved using
-cmdenv EXAMPLE_DIR=/home/example/dictionaries/
但我不知道如何在Hive Transform / MapReduce中执行此操作。
But I do not know how to do this in a Hive Transform/MapReduce.
有什么想法?
推荐答案
你可以用简单的2行bash脚本包装你的脚本来设置环境。例如
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请参阅环境中的 FOO (值为boo)。
my-mapper.script will see FOO (with value "boo") in the environment.
这篇关于将环境变量传递给Hive Transform或MapReduce的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文