pig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jul...@apache.org
Subject svn commit: r1376682 - in /pig/trunk: CHANGES.txt test/org/apache/pig/test/TestBuiltInBagToTupleOrString.java
Date Thu, 23 Aug 2012 20:30:43 GMT
Author: julien
Date: Thu Aug 23 20:30:42 2012
New Revision: 1376682

URL: http://svn.apache.org/viewvc?rev=1376682&view=rev
Log:
PIG-2848: TestBuiltInBagToTupleOrString fails now that mock.Storage enforces not overwriting
output (julien)

Modified:
    pig/trunk/CHANGES.txt
    pig/trunk/test/org/apache/pig/test/TestBuiltInBagToTupleOrString.java

Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1376682&r1=1376681&r2=1376682&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Thu Aug 23 20:30:42 2012
@@ -242,6 +242,8 @@ OPTIMIZATIONS
 
 BUG FIXES
 
+PIG-2848: TestBuiltInBagToTupleOrString fails now that mock.Storage enforces not overwriting
output (julien)
+
 PIG-2884: JobControlCompiler mis-logs after reducer estimation (billgraham)
 
 PIG-2876: Bump up Xerces version (jcoveney)

Modified: pig/trunk/test/org/apache/pig/test/TestBuiltInBagToTupleOrString.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestBuiltInBagToTupleOrString.java?rev=1376682&r1=1376681&r2=1376682&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestBuiltInBagToTupleOrString.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestBuiltInBagToTupleOrString.java Thu Aug 23 20:30:42
2012
@@ -40,11 +40,11 @@ import static org.apache.pig.builtin.moc
 import org.junit.Test;
 
 /**
- * 
+ *
  * Test cases for BagToTuple and BagToString UDFs
- * 
+ *
  * @author hluu
- * 
+ *
  */
 public class TestBuiltInBagToTupleOrString {
 	private BagFactory bf = BagFactory.getInstance();
@@ -58,7 +58,7 @@ public class TestBuiltInBagToTupleOrStri
 		Tuple output = udf.exec(udfInput);
 		assertNull(output);
 	}
-	
+
 	@Test
 	public void testBasicBagToTupleUDF() throws Exception {
 
@@ -202,12 +202,12 @@ public class TestBuiltInBagToTupleOrStri
 		// input contains tuple instead of bag
 		udfInput.set(0, tf.newTuple());
 		BagToTuple udf = new BagToTuple();
-		
+
 		// expecting an exception because the input if of type Tuple, not DataBag
 		udf.exec(udfInput);
 	}
 
-	
+
 	@Test
 	public void testNullInputBagToStringUDF() throws Exception {
 		BagToString udf = new BagToString();
@@ -216,7 +216,7 @@ public class TestBuiltInBagToTupleOrStri
 		String output = udf.exec(udfInput);
 		assertNull(output);
 	}
-	
+
 	@Test(expected=org.apache.pig.backend.executionengine.ExecException.class)
 	public void testInvalidInputForBagToStringUDF() throws Exception {
 		TupleFactory tf = TupleFactory.getInstance();
@@ -224,7 +224,7 @@ public class TestBuiltInBagToTupleOrStri
 		// input contains tuple instead of bag
 		udfInput.set(0, tf.newTuple());
 		BagToString udf = new BagToString();
-		
+
 		// expecting an exception because the input if of type Tuple, not DataBag
 		udf.exec(udfInput);
 	}
@@ -253,7 +253,7 @@ public class TestBuiltInBagToTupleOrStri
 
 		assertEquals("a_5_c_6", result);
 	}
-	
+
 	@Test
 	public void testBasicBagToStringUDF() throws Exception {
 		BagFactory bf = BagFactory.getInstance();
@@ -307,25 +307,25 @@ public class TestBuiltInBagToTupleOrStri
 		udfInput.set(0, inputBag);
 		udfInput.set(1, "_");
 		String result = udf.exec(udfInput);
-		
+
 		assertEquals("a_5_c_6_(d,7)", result);
 	}
-	
+
 	@Test
 	public void testNestedDataElementsForBagToStringUDF() throws Exception {
 
 		DataBag inputBag = buildBagWithNestedTupleAndBag();
-		
+
 		BagToString udf = new BagToString();
 		Tuple udfInput = tf.newTuple(2);
 		udfInput.set(0, inputBag);
 		udfInput.set(1, "*");
-		
+
 		String result = udf.exec(udfInput);
 		assertEquals("a*5*c*6*(d,7)*{(in bag,10)}", result);
 	}
 
-	
+
 	@Test(expected=java.lang.RuntimeException.class)
 	public void testInvalidZeroInputToOutputSchemaForBagToTupleStringUDF() throws Exception
{
 
@@ -337,9 +337,9 @@ public class TestBuiltInBagToTupleOrStri
 
 		assertEquals("schema of BagToTuple input", outputSchema.getField(0).type,
 				DataType.CHARARRAY);
-		
+
 	}
-	
+
 	@Test
 	public void testOutputSchemaForBagToTupleStringUDF() throws Exception {
 
@@ -360,9 +360,9 @@ public class TestBuiltInBagToTupleOrStri
 
 		assertEquals("schema of BagToTuple input", outputSchema.getField(0).type,
 				DataType.CHARARRAY);
-		
+
 	}
-	
+
 	@Test
 	public void testOutputSchemaWithDefaultDelimiterForBagToTupleStringUDF() throws Exception
{
 
@@ -382,9 +382,9 @@ public class TestBuiltInBagToTupleOrStri
 
 		assertEquals("schema of BagToTuple input", outputSchema.getField(0).type,
 				DataType.CHARARRAY);
-		
+
 	}
-	
+
 	@Test(expected=java.lang.RuntimeException.class)
 	public void testInvalidOutputSchemaForBagToTupleStringUDF() throws Exception {
 
@@ -404,17 +404,17 @@ public class TestBuiltInBagToTupleOrStri
 		// expecting an exception because the delimiter is not of type Data.CHARARRAY
 		udf.outputSchema(inputSch);
 	}
-	
+
 	@Test
 	public void testPigScriptForBagToTupleUDF() throws Exception {
 		PigServer pigServer = new PigServer(ExecType.LOCAL);
 		Data data = resetData(pigServer);
-		
+
 		// bag of chararray
 		data.set("foo", "myBag:bag{t:(l:chararray)}",
 				tuple(bag(tuple("a"), tuple("b"), tuple("c"))));
 		pigServer.registerQuery("A = LOAD 'foo' USING mock.Storage();");
-		pigServer.registerQuery("B = FOREACH A GENERATE BagToTuple(myBag) as myBag;");		
+		pigServer.registerQuery("B = FOREACH A GENERATE BagToTuple(myBag) as myBag;");
 	    pigServer.registerQuery("STORE B INTO 'bar' USING mock.Storage();");
 
 	    assertEquals(schema("myBag:(l:chararray)"), data.getSchema("bar"));
@@ -427,18 +427,18 @@ public class TestBuiltInBagToTupleOrStri
 		data.set("foo", "myBag:bag{t:(l:long)}",
 				tuple(bag(tuple(1), tuple(2), tuple(3))));
 		pigServer.registerQuery("A = LOAD 'foo' USING mock.Storage();");
-		pigServer.registerQuery("B = FOREACH A GENERATE BagToTuple(myBag) as myBag;");		
+		pigServer.registerQuery("B = FOREACH A GENERATE BagToTuple(myBag) as myBag;");
 	    pigServer.registerQuery("STORE B INTO 'bar' USING mock.Storage();");
 
 	    out = data.get("bar");
 	    assertEquals(tuple(1, 2, 3), out.get(0).get(0));
 	}
-	
+
 	@Test
 	public void testPigScriptMultipleElmementsPerTupleForBagTupleUDF() throws Exception {
 		PigServer pigServer = new PigServer(ExecType.LOCAL);
 		Data data = resetData(pigServer);
-		
+
 		data.set("foo", "myBag:bag{t:(l:chararray)}",
 				tuple(bag(tuple("a", "b"), tuple("c", "d"), tuple("e", "f"))));
 		pigServer.registerQuery("A = LOAD 'foo' USING mock.Storage();");
@@ -448,122 +448,122 @@ public class TestBuiltInBagToTupleOrStri
 	    List<Tuple> out = data.get("bar");
 	    assertEquals(tuple("a", "b","c", "d", "e", "f"), out.get(0).get(0));
 	}
-	
+
 	@Test
 	public void testPigScriptNestedTupleForBagToTupleDF() throws Exception {
 		PigServer pigServer = new PigServer(ExecType.LOCAL);
 		Data data = resetData(pigServer);
-		
+
 	    Tuple nestedTuple = tuple(bag(tuple("c"), tuple("d")));
 	    data.set("foo", "myBag:bag{t:(l:chararray)}",
 				tuple(bag(tuple("a"), tuple("b"), nestedTuple, tuple("e"))));
-		
+
 		pigServer.registerQuery("A = LOAD 'foo' USING mock.Storage();");
-		pigServer.registerQuery("B = FOREACH A GENERATE BagToTuple(myBag) as myBag;");		
+		pigServer.registerQuery("B = FOREACH A GENERATE BagToTuple(myBag) as myBag;");
 	    pigServer.registerQuery("STORE B INTO 'bar' USING mock.Storage();");
 
 	    List<Tuple> out = data.get("bar");
 	    assertEquals(tuple("a", "b",bag(tuple("c"), tuple("d")), "e"), out.get(0).get(0));
-	    
+
 	}
-	
+
 	@Test
 	public void testPigScriptEmptyBagForBagToTupleUDF() throws Exception {
 		PigServer pigServer = new PigServer(ExecType.LOCAL);
 		Data data = resetData(pigServer);
-		
+
 	    data.set("foo", "myBag:bag{t:(l:chararray)}",
 				tuple(bag()));
-		
+
 		pigServer.registerQuery("A = LOAD 'foo' USING mock.Storage();");
-		pigServer.registerQuery("B = FOREACH A GENERATE BagToTuple(myBag) as myBag;");		
+		pigServer.registerQuery("B = FOREACH A GENERATE BagToTuple(myBag) as myBag;");
 	    pigServer.registerQuery("STORE B INTO 'bar' USING mock.Storage();");
 
 	    List<Tuple> out = data.get("bar");
 	    // empty bag will generate empty tuple
 	    assertEquals(tuple(), out.get(0).get(0));
-	    
+
 	}
-	
+
 	@Test
 	public void testPigScriptrForBagToStringUDF() throws Exception {
 		PigServer pigServer = new PigServer(ExecType.LOCAL);
 		Data data = resetData(pigServer);
-		
+
 		data.set("foo", "myBag:bag{t:(l:chararray)}",
 				tuple(bag(tuple("a"), tuple("b"), tuple("c"))));
 		pigServer.registerQuery("A = LOAD 'foo' USING mock.Storage();");
-		pigServer.registerQuery("B = FOREACH A GENERATE BagToString(myBag) as myBag;");		
+		pigServer.registerQuery("B = FOREACH A GENERATE BagToString(myBag) as myBag;");
 	    pigServer.registerQuery("STORE B INTO 'bar' USING mock.Storage();");
-	    
-	    pigServer.registerQuery("C = FOREACH A GENERATE BagToString(myBag, '==') as myBag;");
	
-	    pigServer.registerQuery("STORE C INTO 'foo' USING mock.Storage();");
+
+	    pigServer.registerQuery("C = FOREACH A GENERATE BagToString(myBag, '==') as myBag;");
+	    pigServer.registerQuery("STORE C INTO 'baz' USING mock.Storage();");
 
 	    List<Tuple> out = data.get("bar");
 	    assertEquals(schema("myBag:chararray"), data.getSchema("bar"));
 	    assertEquals(tuple("a_b_c"), out.get(0));
-	    
-	    out = data.get("foo");
+
+	    out = data.get("baz");
 	    assertEquals(tuple("a==b==c"), out.get(0));
 	}
-	
+
 	@Test
 	public void testPigScriptMultipleElmementsPerTupleForBagToStringUDF() throws Exception {
 		PigServer pigServer = new PigServer(ExecType.LOCAL);
 		Data data = resetData(pigServer);
-		
+
 		data.set("foo", "myBag:bag{t:(l:chararray)}",
 				tuple(bag(tuple("a", "b"), tuple("c", "d"), tuple("e", "f"))));
 		pigServer.registerQuery("A = LOAD 'foo' USING mock.Storage();");
 		pigServer.registerQuery("B = FOREACH A GENERATE BagToString(myBag) as myBag;");
 		pigServer.registerQuery("STORE B INTO 'bar' USING mock.Storage();");
-		
+
 		pigServer.registerQuery("C = FOREACH A GENERATE BagToString(myBag, '^') as myBag;");
-		pigServer.registerQuery("STORE C INTO 'foo' USING mock.Storage();");
+		pigServer.registerQuery("STORE C INTO 'baz' USING mock.Storage();");
 
 	    List<Tuple> out = data.get("bar");
 	    assertEquals(tuple("a_b_c_d_e_f"), out.get(0));
-	    
-	    out = data.get("foo");
+
+	    out = data.get("baz");
 	    assertEquals(tuple("a^b^c^d^e^f"), out.get(0));
 	}
-	
+
 	@Test
 	public void testPigScriptNestedTupleForBagToStringUDF() throws Exception {
 		PigServer pigServer = new PigServer(ExecType.LOCAL);
 		Data data = resetData(pigServer);
-		
+
 	    Tuple nestedTuple = tuple(bag(tuple("c"), tuple("d")));
 	    data.set("foo", "myBag:bag{t:(l:chararray)}",
 				tuple(bag(tuple("a"), tuple("b"), nestedTuple, tuple("e"))));
-		
+
 		pigServer.registerQuery("A = LOAD 'foo' USING mock.Storage();");
-		pigServer.registerQuery("B = FOREACH A GENERATE BagToString(myBag) as myBag;");		
+		pigServer.registerQuery("B = FOREACH A GENERATE BagToString(myBag) as myBag;");
 	    pigServer.registerQuery("STORE B INTO 'bar' USING mock.Storage();");
 
 	    List<Tuple> out = data.get("bar");
 	    assertEquals(tuple("a_b_{(c),(d)}_e"), out.get(0));
-	    
+
 	}
 
 	@Test
 	public void testPigScriptEmptyBagForBagToStringUDF() throws Exception {
 		PigServer pigServer = new PigServer(ExecType.LOCAL);
 		Data data = resetData(pigServer);
-		
+
 	    data.set("foo", "myBag:bag{t:(l:chararray)}",
 				tuple(bag()));
-		
+
 		pigServer.registerQuery("A = LOAD 'foo' USING mock.Storage();");
-		pigServer.registerQuery("B = FOREACH A GENERATE BagToString(myBag) as myBag;");		
+		pigServer.registerQuery("B = FOREACH A GENERATE BagToString(myBag) as myBag;");
 	    pigServer.registerQuery("STORE B INTO 'bar' USING mock.Storage();");
 
 	    List<Tuple> out = data.get("bar");
 	    // empty bag will generate empty string
 	    assertEquals(tuple(""), out.get(0));
-	    
+
 	}
-	
+
 	private DataBag buildBagWithNestedTupleAndBag() throws ExecException {
 		Tuple t1 = tf.newTuple(2);
 		t1.set(0, "a");



Mime
View raw message