pig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jcove...@apache.org
Subject svn commit: r1399922 - in /pig/branches/branch-0.11: CHANGES.txt src/org/apache/pig/builtin/COUNT.java test/org/apache/pig/test/TestBuiltin.java
Date Thu, 18 Oct 2012 23:28:26 GMT
Author: jcoveney
Date: Thu Oct 18 23:28:26 2012
New Revision: 1399922

URL: http://svn.apache.org/viewvc?rev=1399922&view=rev
Log:
PIG-1283: COUNT on null bag causes failure (analog.sony via jcoveney)

Modified:
    pig/branches/branch-0.11/CHANGES.txt
    pig/branches/branch-0.11/src/org/apache/pig/builtin/COUNT.java
    pig/branches/branch-0.11/test/org/apache/pig/test/TestBuiltin.java

Modified: pig/branches/branch-0.11/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.11/CHANGES.txt?rev=1399922&r1=1399921&r2=1399922&view=diff
==============================================================================
--- pig/branches/branch-0.11/CHANGES.txt (original)
+++ pig/branches/branch-0.11/CHANGES.txt Thu Oct 18 23:28:26 2012
@@ -306,6 +306,8 @@ OPTIMIZATIONS
 
 BUG FIXES
 
+PIG-1283: COUNT on null bag causes failure (analog.sony via jcoveney)
+
 PIG-2958: Pig tests do not appear to have a logger attached (daijyc via jcoveney)
 
 PIG-2926: TestPoissonSampleLoader failing on rhel environment (jcoveney)

Modified: pig/branches/branch-0.11/src/org/apache/pig/builtin/COUNT.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.11/src/org/apache/pig/builtin/COUNT.java?rev=1399922&r1=1399921&r2=1399922&view=diff
==============================================================================
--- pig/branches/branch-0.11/src/org/apache/pig/builtin/COUNT.java (original)
+++ pig/branches/branch-0.11/src/org/apache/pig/builtin/COUNT.java Thu Oct 18 23:28:26 2012
@@ -58,6 +58,9 @@ public class COUNT extends EvalFunc<Long
     public Long exec(Tuple input) throws IOException {
         try {
             DataBag bag = (DataBag)input.get(0);
+            if(bag==null)
+                return null;
+
             Iterator it = bag.iterator();
             long cnt = 0;
             while (it.hasNext()){

Modified: pig/branches/branch-0.11/test/org/apache/pig/test/TestBuiltin.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.11/test/org/apache/pig/test/TestBuiltin.java?rev=1399922&r1=1399921&r2=1399922&view=diff
==============================================================================
--- pig/branches/branch-0.11/test/org/apache/pig/test/TestBuiltin.java (original)
+++ pig/branches/branch-0.11/test/org/apache/pig/test/TestBuiltin.java Thu Oct 18 23:28:26
2012
@@ -18,6 +18,7 @@
 package org.apache.pig.test;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
@@ -1001,6 +1002,17 @@ public class TestBuiltin {
     }
 
     @Test
+    public void testCOUNTBagNullCheck() throws Exception{
+
+        DataBag b = null;
+        Tuple t = tupleFactory.getInstance().newTuple(b);
+
+        EvalFunc<Long> count = new COUNT();
+        assertNull(count.exec(t));
+       }
+
+
+    @Test
     public void testCount_ValidNumberOfArguments_WithoutInputSchema_One() throws Exception
{
          File inputFile = createCountInputFile();
          try {



Mime
View raw message