pig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@apache.org
Subject svn commit: r1037954 - in /pig/branches/branch-0.8: CHANGES.txt src/org/apache/pig/impl/logicalLayer/validators/TypeCheckingVisitor.java test/org/apache/pig/test/TestTypeCheckingValidator.java
Date Tue, 23 Nov 2010 00:36:54 GMT
Author: daijy
Date: Tue Nov 23 00:36:53 2010
New Revision: 1037954

URL: http://svn.apache.org/viewvc?rev=1037954&view=rev
Log:
PIG-1741: Lineage fail when flatten a bag

Modified:
    pig/branches/branch-0.8/CHANGES.txt
    pig/branches/branch-0.8/src/org/apache/pig/impl/logicalLayer/validators/TypeCheckingVisitor.java
    pig/branches/branch-0.8/test/org/apache/pig/test/TestTypeCheckingValidator.java

Modified: pig/branches/branch-0.8/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.8/CHANGES.txt?rev=1037954&r1=1037953&r2=1037954&view=diff
==============================================================================
--- pig/branches/branch-0.8/CHANGES.txt (original)
+++ pig/branches/branch-0.8/CHANGES.txt Tue Nov 23 00:36:53 2010
@@ -207,6 +207,8 @@ PIG-1309: Map-side Cogroup (ashutoshc)
 
 BUG FIXES
 
+PIG-1741: Lineage fail when flatten a bag (daijy)
+
 PIG-1739: zero status is returned when pig script fails (yanz)
 
 PIG-1738: New logical plan: Optimized UserFuncExpression.getFieldSchema (daijy)

Modified: pig/branches/branch-0.8/src/org/apache/pig/impl/logicalLayer/validators/TypeCheckingVisitor.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.8/src/org/apache/pig/impl/logicalLayer/validators/TypeCheckingVisitor.java?rev=1037954&r1=1037953&r2=1037954&view=diff
==============================================================================
--- pig/branches/branch-0.8/src/org/apache/pig/impl/logicalLayer/validators/TypeCheckingVisitor.java
(original)
+++ pig/branches/branch-0.8/src/org/apache/pig/impl/logicalLayer/validators/TypeCheckingVisitor.java
Tue Nov 23 00:36:53 2010
@@ -3111,6 +3111,9 @@ public class TypeCheckingVisitor extends
             }            
             Schema.FieldSchema fs = ((ExpressionOperator)op).getFieldSchema();
             if( parentCanonicalName != null ) {
+                // The following line is a work around for PIG-1741. Ideal fix should be
to 
+                // find why the canonical map is empty and create the map
+                if (!fs.findFieldSchema( parentCanonicalName ).getCanonicalMap().isEmpty())
             	fs = fs.findFieldSchema( parentCanonicalName );
             }
             getLoadFuncSpec( fs, loadFuncSpecMap );

Modified: pig/branches/branch-0.8/test/org/apache/pig/test/TestTypeCheckingValidator.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.8/test/org/apache/pig/test/TestTypeCheckingValidator.java?rev=1037954&r1=1037953&r2=1037954&view=diff
==============================================================================
--- pig/branches/branch-0.8/test/org/apache/pig/test/TestTypeCheckingValidator.java (original)
+++ pig/branches/branch-0.8/test/org/apache/pig/test/TestTypeCheckingValidator.java Tue Nov
23 00:36:53 2010
@@ -5936,4 +5936,34 @@ public class TestTypeCheckingValidator e
         assertTrue(cast.getLoadFuncSpec().getClassName().startsWith("PigStorage"));
     }
     
+    @Test
+    // See PIG-1741
+    public void testBagDereference() throws FrontendException {
+        planTester.buildPlan("a = load '1.txt' as (a0);");
+        planTester.buildPlan("b = foreach a generate flatten((bag{tuple(map[])})a0) as b0:map[];");
+        LogicalPlan plan = planTester.buildPlan("c = foreach b generate (long)b0#'key1';");
+
+        // validate
+        CompilationMessageCollector collector = new CompilationMessageCollector() ;
+        TypeCheckingValidator typeValidator = new TypeCheckingValidator() ;
+        typeValidator.validate(plan, collector) ;
+
+        printMessageCollector(collector) ;
+        printTypeGraph(plan) ;
+        planTester.printPlan(plan, TypeCheckingTestUtil.getCurrentMethodName());
+
+        if (collector.hasError()) {
+            throw new AssertionError("Expect no  error") ;
+        }
+
+        LOForEach foreach = (LOForEach)plan.getLeaves().get(0);
+        LogicalPlan foreachPlan = foreach.getForEachPlans().get(0);
+        List<LogicalOperator> projs = foreachPlan.getRoots();
+        LogicalOperator proj = projs.get(0);
+        LogicalOperator maplookup = foreachPlan.getSuccessors( proj ).get( 0 );
+        LogicalOperator cast = foreachPlan.getSuccessors( maplookup ).get( 0 );
+        
+        assertTrue(((LOCast)cast).getLoadFuncSpec().getClassName().equals(PigStorage.class.getName()));
+    }
+    
 }



Mime
View raw message