[ 
https://issues.apache.org/jira/browse/PIG-2111?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Dmitriy V. Ryaboy updated PIG-2111:
-----------------------------------

    Description: 
Using nested classes by referring to them as "package.OuterClass.InnerClass" 
does not work with the register command (package.OuterClass\$InnerClass is the 
correct but unintuitive way to address them).

{code}
package mypackage

public class URLFuncs {

public static class MyEvalFunc extends EvalFunc<String> {
    @Override
    public String exec(Tuple input) throws IOException {
        if (input == null || input.size() == 0)
            return null;
        try {
            Object value = input.get(0);
            if (!(value instanceof String))
                throw new IOException("Cannot convert a " + 
DataType.findTypeName(value));
            String url = (String) value;
            return url.toUpperCase();
        } catch (ExecException ee) {
            throw new IOException("Caught exception processing input row ", ee);
        }
    }


}

{code}

The error is as follows:

{code}

[main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1070: Could not resolve 
mypackage.URLFuncs.MyEvalFunc using imports: 
[org.apache.pig.builtin., org.apache.pig.impl.builtin., com.yahoo.yst.sds.ULT., 
myna.,
org.apache.pig.piggybank.evaluation., 
org.apache.pig.piggybank.evaluation.datetime., 
org.apache.pig.piggybank.evaluation.decode., 
org.apache.pig.piggybank.evaluation.math., 
org.apache.pig.piggybank.evaluation.stats., 
org.apache.pig.piggybank.evaluation.string., 
org.apache.pig.piggybank.evaluation.util., 
org.apache.pig.piggybank.evaluation.util.apachelogparser., 
string., util., math., datetime., sequence., util., 
org.apache.hadoop.zebra.pig., , 
org.apache.pig.builtin., org.apache.pig.impl.builtin.]

{code}

  was:
Using nested classes as below does not work with the register command.

{code}
package mypackage

public class URLFuncs {

public static class MyEvalFunc extends EvalFunc<String> {
    @Override
    public String exec(Tuple input) throws IOException {
        if (input == null || input.size() == 0)
            return null;
        try {
            Object value = input.get(0);
            if (!(value instanceof String))
                throw new IOException("Cannot convert a " + 
DataType.findTypeName(value));
            String url = (String) value;
            return url.toUpperCase();
        } catch (ExecException ee) {
            throw new IOException("Caught exception processing input row ", ee);
        }
    }


}

{code}

The error is as follows:

{code}

[main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1070: Could not resolve 
mypackage.URLFuncs.MyEvalFunc using imports: 
[org.apache.pig.builtin., org.apache.pig.impl.builtin., com.yahoo.yst.sds.ULT., 
myna.,
org.apache.pig.piggybank.evaluation., 
org.apache.pig.piggybank.evaluation.datetime., 
org.apache.pig.piggybank.evaluation.decode., 
org.apache.pig.piggybank.evaluation.math., 
org.apache.pig.piggybank.evaluation.stats., 
org.apache.pig.piggybank.evaluation.string., 
org.apache.pig.piggybank.evaluation.util., 
org.apache.pig.piggybank.evaluation.util.apachelogparser., 
string., util., math., datetime., sequence., util., 
org.apache.hadoop.zebra.pig., , 
org.apache.pig.builtin., org.apache.pig.impl.builtin.]

{code}

       Priority: Minor  (was: Major)
     Issue Type: Wish  (was: Bug)
        Summary: UDF registration for nested classes is unintuitive  (was: UDF 
registration does not work for nested classes)

> UDF registration for nested classes is unintuitive
> --------------------------------------------------
>
>                 Key: PIG-2111
>                 URL: https://issues.apache.org/jira/browse/PIG-2111
>             Project: Pig
>          Issue Type: Wish
>            Reporter: Gianmarco De Francisci Morales
>            Priority: Minor
>
> Using nested classes by referring to them as "package.OuterClass.InnerClass" 
> does not work with the register command (package.OuterClass\$InnerClass is 
> the correct but unintuitive way to address them).
> {code}
> package mypackage
> public class URLFuncs {
> public static class MyEvalFunc extends EvalFunc<String> {
>     @Override
>     public String exec(Tuple input) throws IOException {
>         if (input == null || input.size() == 0)
>             return null;
>         try {
>             Object value = input.get(0);
>             if (!(value instanceof String))
>                 throw new IOException("Cannot convert a " + 
> DataType.findTypeName(value));
>             String url = (String) value;
>             return url.toUpperCase();
>         } catch (ExecException ee) {
>             throw new IOException("Caught exception processing input row ", 
> ee);
>         }
>     }
> }
> {code}
> The error is as follows:
> {code}
> [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1070: Could not resolve 
> mypackage.URLFuncs.MyEvalFunc using imports: 
> [org.apache.pig.builtin., org.apache.pig.impl.builtin., 
> com.yahoo.yst.sds.ULT., myna.,
> org.apache.pig.piggybank.evaluation., 
> org.apache.pig.piggybank.evaluation.datetime., 
> org.apache.pig.piggybank.evaluation.decode., 
> org.apache.pig.piggybank.evaluation.math., 
> org.apache.pig.piggybank.evaluation.stats., 
> org.apache.pig.piggybank.evaluation.string., 
> org.apache.pig.piggybank.evaluation.util., 
> org.apache.pig.piggybank.evaluation.util.apachelogparser., 
> string., util., math., datetime., sequence., util., 
> org.apache.hadoop.zebra.pig., , 
> org.apache.pig.builtin., org.apache.pig.impl.builtin.]
> {code}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to