You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by dv...@apache.org on 2011/11/22 02:19:16 UTC

svn commit: r1204773 - in /pig/trunk: CHANGES.txt src/org/apache/pig/impl/logicalLayer/schema/Schema.java test/org/apache/pig/test/TestSchema.java

Author: dvryaboy
Date: Tue Nov 22 01:19:13 2011
New Revision: 1204773

URL: http://svn.apache.org/viewvc?rev=1204773&view=rev
Log:
Bug in Schema.getPigSchema(ResourceSchema rSchema) improperly adds two level access

Modified:
    pig/trunk/CHANGES.txt
    pig/trunk/src/org/apache/pig/impl/logicalLayer/schema/Schema.java
    pig/trunk/test/org/apache/pig/test/TestSchema.java

Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1204773&r1=1204772&r2=1204773&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Tue Nov 22 01:19:13 2011
@@ -46,6 +46,8 @@ OPTIMIZATIONS
 
 BUG FIXES
 
+PIG-2379: Bug in Schema.getPigSchema(ResourceSchema rSchema) improperly adds two level access (jcoveney via dvryaboy)
+
 PIG-2355: ant clean does not clean e2e test build artifacts (daijy)
 
 PIG-2352: e2e test harness' use of environment variables causes unintended effects between tests (gates)

Modified: pig/trunk/src/org/apache/pig/impl/logicalLayer/schema/Schema.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/impl/logicalLayer/schema/Schema.java?rev=1204773&r1=1204772&r2=1204773&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/impl/logicalLayer/schema/Schema.java (original)
+++ pig/trunk/src/org/apache/pig/impl/logicalLayer/schema/Schema.java Tue Nov 22 01:19:13 2011
@@ -19,24 +19,23 @@ package org.apache.pig.impl.logicalLayer
 
 import java.io.Serializable;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.Collection;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.pig.PigException;
 import org.apache.pig.ResourceSchema;
 import org.apache.pig.ResourceSchema.ResourceFieldSchema;
 import org.apache.pig.data.DataType;
-//import org.apache.pig.impl.logicalLayer.parser.ParseException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.pig.impl.util.MultiMap;
-import org.apache.pig.impl.logicalLayer.FrontendException;
 import org.apache.pig.impl.logicalLayer.CanonicalNamer;
+import org.apache.pig.impl.logicalLayer.FrontendException;
+import org.apache.pig.impl.util.MultiMap;
 
 /**
  * The Schema class encapsulates the notion of a schema for a relational operator.
@@ -1872,7 +1871,6 @@ public class Schema implements Serializa
                     rfs.getSchema() == null ? 
                             null : getPigSchema(rfs.getSchema()), rfs.getType());
             
-            // check if we have a need to set twoLevelAcccessRequired flag
             if(rfs.getType() == DataType.BAG) {
                 if (fs.schema != null) { // allow partial schema
                     if (fs.schema.size() == 1) {
@@ -1880,9 +1878,6 @@ public class Schema implements Serializa
                         if (innerFs.type != DataType.TUPLE) {
                             ResourceFieldSchema.throwInvalidSchemaException();
                         }
-                        if (innerFs.schema != null) { // allow partial schema                      
-                            fs.schema.setTwoLevelAccessRequired(true);
-                        }
                     } else {
                         ResourceFieldSchema.throwInvalidSchemaException();
                     }

Modified: pig/trunk/test/org/apache/pig/test/TestSchema.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestSchema.java?rev=1204773&r1=1204772&r2=1204773&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestSchema.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestSchema.java Tue Nov 22 01:19:13 2011
@@ -45,6 +45,7 @@ import junit.framework.Assert;
 
 import org.apache.pig.ExecType;
 import org.apache.pig.PigServer;
+import org.apache.pig.ResourceSchema;
 import org.apache.pig.data.DataType;
 import org.apache.pig.data.Tuple;
 import org.apache.pig.impl.logicalLayer.FrontendException;
@@ -54,6 +55,7 @@ import org.apache.pig.impl.logicalLayer.
 import org.apache.pig.impl.util.Utils;
 import org.apache.pig.newplan.logical.relational.LogicalSchema;
 import org.apache.pig.newplan.logical.relational.LogicalSchema.MergeMode;
+import org.apache.pig.parser.ParserException;
 import org.junit.Test;
 
 public class TestSchema {
@@ -856,4 +858,11 @@ public class TestSchema {
             Assert.assertTrue(e.getErrorCode()==1031);
         }
     }
+
+    @Test
+    public void testResourceSchemaToSchema() throws ParserException,FrontendException{
+        Schema s1 = Utils.getSchemaFromString("b:bag{t:tuple(name:chararray,age:int)}");
+        Schema s2 = Schema.getPigSchema(new ResourceSchema(s1));
+        Assert.assertTrue(s1.equals(s2));
+}
 }