pig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@apache.org
Subject svn commit: r1196483 - in /pig/trunk: ./ src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/ src/org/apache/pig/pen/ test/org/apache/pig/test/
Date Wed, 02 Nov 2011 07:32:47 GMT
Author: daijy
Date: Wed Nov  2 07:32:46 2011
New Revision: 1196483

URL: http://svn.apache.org/viewvc?rev=1196483&view=rev
Log:
PIG-2275: NullPointerException from ILLUSTRATE

Modified:
    pig/trunk/CHANGES.txt
    pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/UnaryComparisonOperator.java
    pig/trunk/src/org/apache/pig/pen/AugmentBaseDataVisitor.java
    pig/trunk/test/org/apache/pig/test/TestExampleGenerator.java

Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1196483&r1=1196482&r2=1196483&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Wed Nov  2 07:32:46 2011
@@ -156,6 +156,8 @@ PIG-2228: support partial aggregation in
 
 BUG FIXES
 
+PIG-2275: NullPointerException from ILLUSTRATE (daijy)
+
 PIG-2119: DuplicateForEachColumnRewrite makes assumptions about the position of LOGGenerate
in the plan (daijy)
 
 PIG-2290: TOBAG wraps tuple parameters in another tuple (ryan.hoegg via thejas)

Modified: pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/UnaryComparisonOperator.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/UnaryComparisonOperator.java?rev=1196483&r1=1196482&r2=1196483&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/UnaryComparisonOperator.java
(original)
+++ pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/UnaryComparisonOperator.java
Wed Nov  2 07:32:46 2011
@@ -55,7 +55,7 @@ public abstract class UnaryComparisonOpe
     @Override
     public Tuple illustratorMarkup(Object in, Object out, int eqClassIndex) {
         if(illustrator != null) {
-
+            illustrator.setSubExpResult(eqClassIndex == 0);
         }
         return null;
     }

Modified: pig/trunk/src/org/apache/pig/pen/AugmentBaseDataVisitor.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/pen/AugmentBaseDataVisitor.java?rev=1196483&r1=1196482&r2=1196483&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/pen/AugmentBaseDataVisitor.java (original)
+++ pig/trunk/src/org/apache/pig/pen/AugmentBaseDataVisitor.java Wed Nov  2 07:32:46 2011
@@ -61,6 +61,7 @@ import org.apache.pig.newplan.logical.ex
 import org.apache.pig.newplan.logical.expression.LessThanEqualExpression;
 import org.apache.pig.newplan.logical.relational.LOLoad;
 import org.apache.pig.newplan.logical.relational.LogicalPlan;
+import org.apache.pig.newplan.logical.expression.IsNullExpression;
 import org.apache.pig.newplan.logical.expression.ModExpression;
 import org.apache.pig.newplan.logical.expression.LogicalExpression;
 import org.apache.pig.newplan.logical.expression.MultiplyExpression;
@@ -69,6 +70,7 @@ import org.apache.pig.newplan.logical.ex
 import org.apache.pig.newplan.logical.expression.OrExpression;
 import org.apache.pig.newplan.logical.expression.ProjectExpression;
 import org.apache.pig.newplan.logical.expression.RegexExpression;
+import org.apache.pig.newplan.logical.expression.UserFuncExpression;
 import org.apache.pig.newplan.logical.relational.LOSort;
 import org.apache.pig.newplan.logical.relational.LOSplit;
 import org.apache.pig.newplan.logical.relational.LOStore;
@@ -510,10 +512,10 @@ public class AugmentBaseDataVisitor exte
         } catch (Exception e) {
             log
                     .error("Error visiting Load during Augmentation phase of Example Generator!
"
-                            + e.getMessage());
+                            + e.getMessage(), e);
             throw new FrontendException(
                     "Error visiting Load during Augmentation phase of Example Generator!
"
-                            + e.getMessage());
+                            + e.getMessage(), e);
         }
     }
 
@@ -946,6 +948,12 @@ public class AugmentBaseDataVisitor exte
                     invert);
         else if (pred instanceof NotExpression)
             GenerateMatchingTupleHelper(t, (NotExpression) pred, invert);
+        else if (pred instanceof IsNullExpression)
+            GenerateMatchingTupleHelper(t, (IsNullExpression) pred, invert);
+        else if (pred instanceof UserFuncExpression)
+            // Don't know how to generate input tuple for UDF, return null
+            // to suppress the generation 
+            t = null;
         else
             throw new FrontendException("Unknown operator in filter predicate");
     }
@@ -1151,6 +1159,15 @@ public class AugmentBaseDataVisitor exte
         GenerateMatchingTupleHelper(t, input, !invert);
 
     }
+    
+    void GenerateMatchingTupleHelper(Tuple t, IsNullExpression op, boolean invert)
+            throws FrontendException, ExecException {
+        byte type = op.getExpression().getType();
+        if (!invert)
+            t.set(0, null);
+        else
+            t.set(0, generateData(type, "0"));
+    }
 
     Object GetUnequalValue(Object v) {
         byte type = DataType.findType(v);

Modified: pig/trunk/test/org/apache/pig/test/TestExampleGenerator.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestExampleGenerator.java?rev=1196483&r1=1196482&r2=1196483&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestExampleGenerator.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestExampleGenerator.java Wed Nov  2 07:32:46 2011
@@ -361,4 +361,33 @@ public class TestExampleGenerator {
 
         assertTrue(derivedData != null);
     }
+    
+    //see PIG-2275
+    @Test
+    public void testFilterWithIsNull() throws ExecException, IOException {
+        PigServer pigServer = new PigServer(pigContext);
+
+        pigServer.registerQuery("A = load " + A
+                + " using PigStorage() as (x : int, y : int);");
+        pigServer.registerQuery("B = filter A by x is not null;");
+
+        Map<Operator, DataBag> derivedData = pigServer.getExamples("B");
+
+        assertTrue(derivedData != null);
+    }
+    
+    @Test
+    public void testFilterWithUDF() throws ExecException, IOException {
+        PigServer pigServer = new PigServer(pigContext);
+
+        pigServer.registerQuery("A = load " + A
+                + " using PigStorage() as (x : int, y : int);");
+        pigServer.registerQuery("B = group A by x;");
+        pigServer.registerQuery("C = filter B by NOT IsEmpty(A.y);");
+
+        Map<Operator, DataBag> derivedData = pigServer.getExamples("C");
+
+        assertTrue(derivedData != null);
+    }
+
 }



Mime
View raw message