通过猪脚本传递参数时出错 [英] Error getting when passing parameter through pig script

查看:25
本文介绍了通过猪脚本传递参数时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

pig -P/mapr/ANALYTICS/apps/PigTest/pig.properties -f pig_if_condition.pig

<块引用>

SLF4J:类路径包含多个 SLF4J 绑定.SLF4J:在 [jar:file:/opt/mapr/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class] 中找到绑定SLF4J:在 [jar:file:/opt/mapr/hbase/hbase-0.98.4/lib/slf4j-log4j12-1.6.4.jar!/org/slf4j/impl/StaticLoggerBinder.class] 中找到绑定SLF4J:有关解释,请参阅 http://www.slf4j.org/codes.html#multiple_bindings.SLF4J:实际绑定类型为 [org.slf4j.impl.Log4jLoggerFactory]15/05/20 15:42:52 错误猪.主要:错误 2999:意外的内部错误.无法解析属性文件

'/mapr/ANALYTICS/apps/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)在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)在 java.lang.reflect.Method.invoke(Method.java:606)在 org.apache.hadoop.util.RunJar.main(RunJar.java:212)

猪脚本是:

 test = load '$path' USING PigStorage(',') AS (i​​p:chararray,country:chararray);转储测试;

解决方案

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

快捷指令:

  1. -m 与 -param_file 相同
  2. -p 与 -param 相同

用法:

 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);转储 A;

属性文件:a.properties

INPUT=a.csv

测试文件:a.csv

IN,印度美国,美国英国,英国

输出:

 (IN,India)(美国,美国)(英国,英国)

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;

解决方案

-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)

这篇关于通过猪脚本传递参数时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆