You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pig.apache.org by "Santhosh Srinivasan (JIRA)" <ji...@apache.org> on 2008/06/03 02:37:44 UTC

[jira] Commented: (PIG-159) Make changes to the parser to support new types functionality

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

Santhosh Srinivasan commented on PIG-159:
-----------------------------------------

The define statement as specified in the types functional specification is like a function type declaration in C. The existing define syntax in Pig is for specifying the UDF along with the constructor argument. Examples will illustrate the difference.

{code}

--Existing Pig

define myFunc org.apache.pig.test.MyFunc('foo');

--Proposed syntax in the types functional specification

define myFunc = int org.apache.pig.test.MyFunc(a:int, b: tuple(b1: int, b2: float));

{code}

As seen in the aforementioned example, we are changing the semantics of define. The parser in the types branch has the implementation proposed in the types functional specification. In order to ensure backward compatibility and consistency, I will be rolling back the changes in the parser to conform to the existing pig semantics for define.

I will introduce a 'declare' statement (no syntax yet) that will allow the user to specify the number and type of the function parameters. In short, the define in the parser in the types branch will be converted to a declare with a slightly modified syntax. This will allow the parser to check for the number and types of the actual parameters to the UDF.

In the current implementation of UDFs, the exec method accepts a tuple as input. There are no options to pass any type other than that of a tuple. This flexibility is necessary for the users to be able to write UDFs that can accept types other than tuple. Irrespective of this change, the parser can support checking for number and types of the UDF arguments.

Thoughts?

> Make changes to the parser to support new types functionality
> -------------------------------------------------------------
>
>                 Key: PIG-159
>                 URL: https://issues.apache.org/jira/browse/PIG-159
>             Project: Pig
>          Issue Type: Sub-task
>          Components: impl
>            Reporter: Alan Gates
>            Assignee: Alan Gates
>         Attachments: parser_chages_v10.patch, parser_chages_v11.patch, parser_chages_v12.patch, parser_chages_v13.patch, parser_chages_v5.patch, parser_chages_v6.patch, parser_chages_v7.patch, parser_chages_v8.patch, parser_chages_v9.patch
>
>
> In order to support the new types functionality described in http://wiki.apache.org/pig/PigTypesFunctionalSpec, the parse needs to change in the following ways:
> 1) AS needs to support types in addition to aliases.  So where previously it was legal to say:
> a = load 'myfile' as a, b, c;
> it will now also be legal to say
> a = load 'myfile' as a integer, b float, c chararray;
> 2) Non string constants need to be supported.  This includes non-string atomic types (integer, long, float, double) and the non-atomic types bags, tuples, and maps.
> 3) A cast operator needs to be added so that fields can be explicitly casted.
> 4) Changes to DEFINE, to allow users to declare arguments and return types for UDFs

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