通过pig脚本传递参数时出错

时间:2015-05-20 14:29:25

标签: hadoop apache-pig

当我尝试使用属性文件调用pig脚本时,我收到错误:

pig -P /mapr/ANALYTICS/apps/PigTest/pig.properties -f pig_if_condition.pig
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/mapr/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/mapr/hbase/hbase-0.98.4/lib/slf4j-log4j12-1.6.4.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
15/05/20 15:42:52 ERROR pig.Main: ERROR 2999: Unexpected internal error. Unable to parse properties file
     

'/ MAPR /分析/应用/ PigTest / pig.properties'       15/05/20 15:42:52 WARN pig.Main:没有要写入的日志文件。       15/05/20 15:42:52错误pig.Main:java.lang.RuntimeException:无法解析属性文件   '/mapr/ANALYTICS/apps/PigTest/pig.properties'               在org.apache.pig.Main.run(Main.java:343)               在org.apache.pig.Main.main(Main.java:156)               at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)               at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)               at java.lang.reflect.Method.invoke(Method.java:606)               在org.apache.hadoop.util.RunJar.main(RunJar.java:212)

Pig脚本是:

 test = load '$path' USING PigStorage(',') AS (ip:chararray,country:chararray);
 DUMP test;

1 个答案:

答案 0 :(得分:1)

-param(-p)是指定单个参数。要指定参数文件,我们必须使用 -param_file 属性。

快捷命令:

  1. -m与-param_file
  2. 相同
  3. -p与-param相同
  4. 用法:

     pig  -param_file {property_file} -f {pig_file}
    

    示例:

     pig  -param_file a.properties -f a.pig
    

    猪脚本:a.pig

    A = LOAD '$INPUT' USING  PigStorage(',') AS (country_code:chararray, country_name:chararray);
    DUMP A;
    

    属性文件:a.properties

    INPUT=a.csv
    

    测试文件:a.csv

    IN,India
    US,United States
    UK,United Kingdom
    

    输出

     (IN,India)
     (US,United States)
     (UK,United Kingdom)