Error getting when passing parameter through pig script

最后都变了- 提交于 2019-12-13 06:38:32

问题


When I'm trying to invoke pig script with property file then I'm getting error:

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/ANALYTICS/apps/PigTest/pig.properties' 15/05/20 15:42:52 WARN pig.Main: There is no log file to write to. 15/05/20 15:42:52 ERROR pig.Main: java.lang.RuntimeException: Unable to parse properties file '/mapr/ANALYTICS/apps/PigTest/pig.properties' at org.apache.pig.Main.run(Main.java:343) at 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) at org.apache.hadoop.util.RunJar.main(RunJar.java:212)

Pig script is:

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

回答1:


-param (-p) is to specify a single parameter. To specify parameter file we have to use -param_file attribute.

Short Cut Commands :

  1. -m same as -param_file
  2. -p same as -param

Usage :

 pig  -param_file {property_file} -f {pig_file}

example :

 pig  -param_file a.properties -f a.pig

Pig Script : a.pig

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

Property File : a.properties

INPUT=a.csv

test file : a.csv

IN,India
US,United States
UK,United Kingdom

Output :

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


来源:https://stackoverflow.com/questions/30352659/error-getting-when-passing-parameter-through-pig-script

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