错误 1070 Apache Pig,使用内置 UDF

ERROR 1070 Apache Pig, using built-in UDF

, this, and this,没有解决我的问题。他们都在制作自己的 UDF。我想使用内置的 UDF。 任意 内置 UDF。我尝试过的每个 UDF 都出现相同或相似的错误。

 FOO = LOAD 'filepath/data.csv' 
 USING PigStorage(',') 
 AS (name:string, age:int, kilograms:double);

 BAR = FOREACH FOO GENERATE [=10=], , , kilograms*2.2 AS pounds;

这按预期工作,基本上创建了与 FOO 相同的关系,但多了一个将 KG 转换为 LBS 的列。

但是如果我想使用类似获取公斤的对数刻度的东西,就像这样:

 BAR2 = FOREACH FOO GENERATE [=11=], , , log(kilograms) AS logscaleKG;

我收到以下错误(或类似错误):

 ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1070: Could not resolve log using imports: [, java.lang., org.apache.pig.builtin., org.apache.pig.impl.builtin.]

似乎没有 UDF 在 FOREACH GENERATE 中工作。

猪对大写有点挑剔,你要大写log。例如,我可以 运行 此代码在新的 Hortonworks 沙盒上运行良好。

$ hdfs dfs -cat /tmp/kg.csv
one,1
two,2
three,3

+

grunt> a = LOAD '/tmp/kg.csv' USING PigStorage(',') AS (txt:chararray, val:int);
grunt> b = FOREACH a GENERATE txt, val, LOG(val);
grunt> DUMP b;
... # Running some MapReduces
(one,1,0.0)
(two,2,0.6931471805599453)
(three,3,1.0986122886681098)