pig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jcove...@apache.org
Subject svn commit: r1399926 - in /pig/trunk: src/org/apache/pig/builtin/COUNT.java test/org/apache/pig/test/TestBuiltin.java
Date Thu, 18 Oct 2012 23:48:27 GMT
Author: jcoveney
Date: Thu Oct 18 23:48:27 2012
New Revision: 1399926

URL: http://svn.apache.org/viewvc?rev=1399926&view=rev
Log:
Properly commit PIG-1283

Modified:
    pig/trunk/src/org/apache/pig/builtin/COUNT.java
    pig/trunk/test/org/apache/pig/test/TestBuiltin.java

Modified: pig/trunk/src/org/apache/pig/builtin/COUNT.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/builtin/COUNT.java?rev=1399926&r1=1399925&r2=1399926&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/builtin/COUNT.java (original)
+++ pig/trunk/src/org/apache/pig/builtin/COUNT.java Thu Oct 18 23:48:27 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/trunk/test/org/apache/pig/test/TestBuiltin.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestBuiltin.java?rev=1399926&r1=1399925&r2=1399926&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestBuiltin.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestBuiltin.java Thu Oct 18 23:48:27 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