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

Santhosh Srinivasan commented on PIG-773:
-----------------------------------------

Comments:

1. Minor comment - the comment on the empty productions all have the same text 
For tuple and bag, it should be changed to tuple and bag respectively

{code}
+       |{ } // Match the empty content in map.
{code}

2. I am not sure about the test case testEmptyBagConstRecursive. Here the bag 
contains an empty tuple. As a result, the field schema for the bag should 
contain the schema of the empty tuple. The test case will probably fail.

{code}
+    @Test
+    public void testEmptyBagConstRecursive() throws FrontendException{
+       
+        LogicalPlan lp = buildPlan("a = foreach (load 'b') generate {()};");
+        LOForEach foreach = (LOForEach) lp.getLeaves().get(0);
+        
+        Schema.FieldSchema bagFs = new 
Schema.FieldSchema(null,null,DataType.BAG);
+        Schema expectedSchema = new Schema(bagFs);
+       
+        assertTrue(Schema.equals(foreach.getSchema(), expectedSchema, false, 
true));
+    }

{code}

3. There are no tests that check if the empty constants are actually created, 
i.e., there are no checks for expected empty constants. The test below checks 
if the parser can parse the new syntax for empty constants. In addition, the 
values generated by the parser have to checked against expected values for 
these constants.

{code}
+    @Test
+    public void testRandomEmptyConst(){
+        // Various random scripts to test recursive nature of parser with 
empty constants.
+       
+        buildPlan("a = foreach (load 'b') generate {({})};");
+        buildPlan("a = foreach (load 'b') generate ({()});");
+        buildPlan("a = foreach (load 'b') generate {(),()};");
+        buildPlan("a = foreach (load 'b') generate ({},{});");
+        buildPlan("a = foreach (load 'b') generate ((),());");
+        buildPlan("a = foreach (load 'b') generate ([],[]);");
+        buildPlan("a = foreach (load 'b') generate {({},{})};");
+        buildPlan("a = foreach (load 'b') generate {([],[])};");
+        buildPlan("a = foreach (load 'b') generate (({},{}));");
+        buildPlan("a = foreach (load 'b') generate (([],[]));");
+    }
{code}

> Empty complex constants (empty bag, empty tuple and empty map) should be 
> supported
> ----------------------------------------------------------------------------------
>
>                 Key: PIG-773
>                 URL: https://issues.apache.org/jira/browse/PIG-773
>             Project: Pig
>          Issue Type: Bug
>    Affects Versions: 0.3.0
>            Reporter: Pradeep Kamath
>            Priority: Minor
>         Attachments: pig-773.patch, pig-773_v2.patch
>
>
> We should be able to create empty bag constant using {}, empty tuple constant 
> using (), empty map constant using [] within a pig script

-- 
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