[ 
https://issues.apache.org/jira/browse/PIG-320?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12615247#action_12615247
 ] 

Pi Song commented on PIG-320:
-----------------------------

I'm curios about this.
Then if the outputSchema implementation is provided, why do extract only the 
first field? Isn't it more intuitive to use the whole schema directly? My 
suggestion might break some stuffs but it seems a bit better for users.

{noformat}
        Schema udfSchema = ef.outputSchema(inputSchema);
        if (null != udfSchema) {
            Schema.FieldSchema fs;
            try {
                fs = udfSchema.getField(0);
            } catch (ParseException pe) {
                throw new VisitorException(pe.getMessage());
            }
            func.setType(fs.type);
            try {
                func.setFieldSchema(fs);
            } catch (FrontendException fe) {
                throw new VisitorException(fe.getMessage());
            }
        } else {
            func.setType(DataType.findType(ef.getReturnType()));
        }

{noformat}

> The parser/type checker should use the getSchema method of UDFs to deduce 
> return type/schema
> --------------------------------------------------------------------------------------------
>
>                 Key: PIG-320
>                 URL: https://issues.apache.org/jira/browse/PIG-320
>             Project: Pig
>          Issue Type: Bug
>          Components: impl
>    Affects Versions: types_branch
>            Reporter: Santhosh Srinivasan
>            Assignee: Santhosh Srinivasan
>             Fix For: types_branch
>
>         Attachments: udf_outputSchema.patch
>
>
> Currently, the parser/type checker uses the getReturnType to deduce the 
> return type of the user defined function (UDF). This mechanism is 
> satisfactory only for basic types (int, long, ...); for composite types 
> (tuple, bag), the schema is also required.The abstract class EvalFunc 
> interface exposes the outputSchema to deduce the return type/schema of the 
> UDF. The parser/type checker should use this method to figure out the return 
> type/schema of the UDF and use it appropriately. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to