You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pig.apache.org by "Rohini Palaniswamy (JIRA)" <ji...@apache.org> on 2015/12/07 03:32:11 UTC
[jira] [Commented] (PIG-4756) Groovy algebraic UDF only works when
return type is long
[ https://issues.apache.org/jira/browse/PIG-4756?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15044281#comment-15044281 ]
Rohini Palaniswamy commented on PIG-4756:
-----------------------------------------
PIG-4744 patch which is already committed is mixed with this.
> Groovy algebraic UDF only works when return type is long
> --------------------------------------------------------
>
> Key: PIG-4756
> URL: https://issues.apache.org/jira/browse/PIG-4756
> Project: Pig
> Issue Type: Bug
> Reporter: Daniel Dai
> Assignee: Daniel Dai
> Attachments: PIG-4756-0.patch
>
>
> The following groovy UDF does not work:
> {code}
> import org.apache.pig.scripting.groovy.AlgebraicInitial;
> import org.apache.pig.scripting.groovy.AlgebraicIntermed;
> import org.apache.pig.scripting.groovy.AlgebraicFinal;
> import java.lang.Math;
> class GroovyUDFs {
> @AlgebraicInitial('max')
> public static Tuple initial(Tuple t) {
> return t[1].next();
> }
> @AlgebraicIntermed('max')
> public static Tuple intermed(Tuple t) {
> double max = -1;
> for (Tuple inner: t[1]) {
> max = Math.max(max, inner[0]);
> }
> return [max];
> }
> @AlgebraicFinal('max')
> public static double algFinal(Tuple t) {
> double max = -1;
> for (Tuple inner: t[1]) {
> max = Math.max(max, inner[0]);
> }
> return max;
> }
> }
> {code}
> Error message:
> {code}
> Caused by: java.lang.RuntimeException: could not instantiate 'org.apache.pig.scripting.groovy.GroovyAlgebraicEvalFunc$DoubleGroovyAlgebraicEvalFunc$Final' with arguments 'null'
> at org.apache.pig.impl.PigContext.instantiateFuncFromSpec(PigContext.java:766)
> at org.apache.pig.EvalFunc.getReturnTypeFromSpec(EvalFunc.java:153)
> at org.apache.pig.EvalFunc.<init>(EvalFunc.java:144)
> at org.apache.pig.AccumulatorEvalFunc.<init>(AccumulatorEvalFunc.java:33)
> at org.apache.pig.AlgebraicEvalFunc.<init>(AlgebraicEvalFunc.java:82)
> at org.apache.pig.scripting.groovy.GroovyAlgebraicEvalFunc.<init>(GroovyAlgebraicEvalFunc.java:39)
> at org.apache.pig.scripting.groovy.GroovyAlgebraicEvalFunc$DoubleGroovyAlgebraicEvalFunc.<init>(GroovyAlgebraicEvalFunc.java:199)
> ... 42 more
> Caused by: java.lang.InstantiationException: org.apache.pig.scripting.groovy.GroovyAlgebraicEvalFunc$DoubleGroovyAlgebraicEvalFunc$Final
> at java.lang.Class.newInstance(Class.java:364)
> at org.apache.pig.impl.PigContext.instantiateFuncFromSpec(PigContext.java:736)
> ... 48 more
> {code}
> It works when the return type is long.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)