gpt4 book ai didi

bash - Pig 0.12.0 不会使用反引号执行时区更改的 shell 命令

转载 作者:可可西里 更新时间:2023-11-01 16:53:52 26 4
gpt4 key购买 nike

我在亚马逊 EMR 上将 Hue 用于 PIG 脚本。我想进行 shell 调用以将特定时区中的日期获取到一个变量中,我将使用该变量来定义用于将输出写入的输出文件夹路径。最终我想使用 if else fi 循环从一周中获取特定日期,因此时区将在命令的不同位置提及。

示例脚本

ts = LOAD 's3://testbucket1/input/testdata-00000.gz' USING PigStorage('\t');
STORE ts INTO 's3://testbucket1/$OUTPUT_FOLDER' USING PigStorage('\t');

Hue 中 Pig 参数定义:

  1. 这有效:OUTPUT FOLDER = `/bin/date +%Y%m%d`
  2. 这不起作用:OUTPUT FOLDER = `TZ=America/New_York/bin/date +%Y%m%d`

这两个命令都可以在 bash shell 中完美执行。但是第二个命令给出了以下错误:

2015-06-23 21:43:42,901 [main] INFO org.apache.pig.tools.parameters.PreprocessorContext - Executing command : TZ=America/Phoenix /bin/date +%Y%m%d 2015-06-23 21:43:42,913 [main] ERROR org.apache.pig.Main - ERROR 2999: Unexpected internal error. Error executing shell command: TZ=America/Phoenix /bin/date +%Y%m%d. Command exit with exit code of 126

From the GNU manual:如果找到命令但不可执行,则返回状态为 126。

我该如何解决?

配置详情:

  • AMI 版本:3.7.0
  • Hadoop 分布:Amazon 2.4.0
  • 应用程序:Hive 0.13.1、Pig 0.12.0、Impala 1.2.4、Hue
  • 底层 shell :bash
  • 用户:hadoop(同时使用 Pig 和 Bash)

如果您需要任何说明,请对此问题发表评论。我会根据需要更新它。

EDIT: Under the hood, Pig calculates the value by executing "bash -c exec (command)" and assigning it to the variable, where (command) is whatever we put as a value for the variable in Hue

最佳答案

如果我这样做:

date --date='TZ="America/Los_Angeles"' '+%Y%m%d'
20150624

例如

%default date_dir `date --date='TZ="America/Los_Angeles"' '+%Y%m%d'`;

关于bash - Pig 0.12.0 不会使用反引号执行时区更改的 shell 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31014230/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com