Author: thejas
Date: Tue Sep  7 20:09:04 2010
New Revision: 993512

URL: http://svn.apache.org/viewvc?rev=993512&view=rev
Log:
PIG-1595: casting relation to scalar- problem with handling of data from non 
PigStorage loaders - PIG-1595.2.patch

Modified:
    hadoop/pig/trunk/test/org/apache/pig/test/TestScalarAliases.java
    hadoop/pig/trunk/test/org/apache/pig/test/Util.java

Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestScalarAliases.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestScalarAliases.java?rev=993512&r1=993511&r2=993512&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestScalarAliases.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestScalarAliases.java Tue Sep  7 
20:09:04 2010
@@ -487,7 +487,7 @@ public class TestScalarAliases  {
 
     }
     
-/*    @Test
+    @Test
     public void testScalarErrMultipleRowsInInput() throws Exception{
         pigServer = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
         String[] input = {
@@ -498,15 +498,17 @@ public class TestScalarAliases  {
         String INPUT_FILE = "table_testScalarAliasesMulRows";
         Util.createInputFile(cluster, INPUT_FILE, input);
         pigServer.registerQuery("A = LOAD '" + INPUT_FILE +  "' as (a0: long, 
a1: double);");
-        pigServer.registerQuery("B = LOAD '" + INPUT_FILE +  "' as (a0: long, 
a1: double);");
+        pigServer.registerQuery("B = LOAD '" + INPUT_FILE +  "' as (b0: long, 
b1: double);");
         pigServer.registerQuery("C = foreach A generate $0, B.$0;");
         try {
             pigServer.openIterator("C");
             fail("exception expected - scalar input has multiple rows");
         } catch (IOException pe){
-            assertTrue(pe.getCause().getMessage().contains("Scalar has more 
than one row in the output"));
+            Util.checkStrContainsSubStr(pe.getCause().getMessage(),
+                    "Scalar has more than one row in the output"
+            );
         }
-    }*/
+    }
 
 
     // See PIG-1434

Modified: hadoop/pig/trunk/test/org/apache/pig/test/Util.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/Util.java?rev=993512&r1=993511&r2=993512&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/Util.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/Util.java Tue Sep  7 20:09:04 2010
@@ -18,6 +18,7 @@
 package org.apache.pig.test;
 
 import static java.util.regex.Matcher.quoteReplacement;
+import static org.junit.Assert.fail;
 
 import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
@@ -25,7 +26,6 @@ import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
-import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStream;
@@ -37,7 +37,6 @@ import java.io.PrintWriter;
 import java.io.StringReader;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -73,7 +72,6 @@ import org.apache.pig.impl.logicalLayer.
 import org.apache.pig.impl.logicalLayer.parser.QueryParser;
 import org.apache.pig.impl.logicalLayer.schema.Schema;
 import org.apache.pig.newplan.logical.optimizer.LogicalPlanPrinter;
-import org.apache.pig.tools.grunt.Grunt;
 import org.apache.pig.tools.grunt.GruntParser;
 
 import com.google.common.base.Function;
@@ -399,7 +397,18 @@ public class Util {
          Assert.assertEquals("Comparing actual and expected results. ",
                  expectedResList, actualResList);
      }
-     
+
+     /**
+      * Check if subStr is a subString of str . calls org.junit.Assert.fail if 
it is not 
+      * @param str
+      * @param subStr
+      */
+     static public void checkStrContainsSubStr(String str, String subStr){
+         if(!str.contains(subStr)){
+             fail("String '"+ subStr + "' is not a substring of '" + str + 
"'");
+         }
+     }
+
        /**
         * Utility method to copy a file form local filesystem to the dfs on
         * the minicluster for testing in mapreduce mode


Reply via email to