You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by th...@apache.org on 2011/01/27 01:47:22 UTC
svn commit: r1063938 - in /pig/branches/branch-0.8: CHANGES.txt
src/org/apache/pig/PigServer.java
src/org/apache/pig/newplan/logical/relational/LOLoad.java
test/org/apache/pig/test/TestUDFContext.java
Author: thejas
Date: Thu Jan 27 00:47:21 2011
New Revision: 1063938
URL: http://svn.apache.org/viewvc?rev=1063938&view=rev
Log:
PIG-1776: changing statement corresponding to alias after explain , then
doing dump gives incorrect result
Modified:
pig/branches/branch-0.8/CHANGES.txt
pig/branches/branch-0.8/src/org/apache/pig/PigServer.java
pig/branches/branch-0.8/src/org/apache/pig/newplan/logical/relational/LOLoad.java
pig/branches/branch-0.8/test/org/apache/pig/test/TestUDFContext.java
Modified: pig/branches/branch-0.8/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.8/CHANGES.txt?rev=1063938&r1=1063937&r2=1063938&view=diff
==============================================================================
--- pig/branches/branch-0.8/CHANGES.txt (original)
+++ pig/branches/branch-0.8/CHANGES.txt Thu Jan 27 00:47:21 2011
@@ -213,6 +213,9 @@ PIG-1309: Map-side Cogroup (ashutoshc)
BUG FIXES
+PIG-1776: changing statement corresponding to alias after explain , then
+ doing dump gives incorrect result (thejas)
+
PIG-1800: Missing Signature for maven staging release (rding)
PIG-1815: pig task retains used instances of PhysicalPlan (thejas)
Modified: pig/branches/branch-0.8/src/org/apache/pig/PigServer.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.8/src/org/apache/pig/PigServer.java?rev=1063938&r1=1063937&r2=1063938&view=diff
==============================================================================
--- pig/branches/branch-0.8/src/org/apache/pig/PigServer.java (original)
+++ pig/branches/branch-0.8/src/org/apache/pig/PigServer.java Thu Jan 27 00:47:21 2011
@@ -99,6 +99,7 @@ import org.apache.pig.impl.util.LogUtils
import org.apache.pig.impl.util.ObjectSerializer;
import org.apache.pig.impl.util.Pair;
import org.apache.pig.impl.util.PropertiesUtil;
+import org.apache.pig.impl.util.UDFContext;
import org.apache.pig.impl.util.Utils;
import org.apache.pig.newplan.logical.LogicalPlanMigrationVistor;
import org.apache.pig.newplan.logical.optimizer.LogicalPlanOptimizer;
@@ -1647,6 +1648,9 @@ public class PigServer {
graph.processedStores = processedStores;
graph.fileNameMap = fileNameMap;
+ //reset udf properties
+ UDFContext.getUDFContext().reset();
+
try {
for (Iterator<String> it = getScriptCache().iterator(); it.hasNext(); lineNumber++) {
if (isBatchOn()) {
Modified: pig/branches/branch-0.8/src/org/apache/pig/newplan/logical/relational/LOLoad.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.8/src/org/apache/pig/newplan/logical/relational/LOLoad.java?rev=1063938&r1=1063937&r2=1063938&view=diff
==============================================================================
--- pig/branches/branch-0.8/src/org/apache/pig/newplan/logical/relational/LOLoad.java (original)
+++ pig/branches/branch-0.8/src/org/apache/pig/newplan/logical/relational/LOLoad.java Thu Jan 27 00:47:21 2011
@@ -199,4 +199,10 @@ public class LOLoad extends LogicalRelat
public void resetUid() {
uidOnlySchema = null;
}
+
+ @Override
+ public String toString(){
+ String str = super.toString();
+ return (str + "RequiredFields:" + requiredFields);
+ }
}
Modified: pig/branches/branch-0.8/test/org/apache/pig/test/TestUDFContext.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.8/test/org/apache/pig/test/TestUDFContext.java?rev=1063938&r1=1063937&r2=1063938&view=diff
==============================================================================
--- pig/branches/branch-0.8/test/org/apache/pig/test/TestUDFContext.java (original)
+++ pig/branches/branch-0.8/test/org/apache/pig/test/TestUDFContext.java Thu Jan 27 00:47:21 2011
@@ -17,35 +17,29 @@
*/
package org.apache.pig.test;
+import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import java.io.File;
import java.io.FileWriter;
-import java.io.IOException;
import java.util.Iterator;
import java.util.Properties;
-import org.apache.pig.EvalFunc;
import org.apache.pig.ExecType;
import org.apache.pig.PigServer;
import org.apache.pig.builtin.PigStorage;
import org.apache.pig.data.Tuple;
-import org.apache.pig.impl.io.BufferedPositionedInputStream;
import org.apache.pig.impl.io.FileLocalizer;
-import org.apache.pig.impl.logicalLayer.schema.Schema;
import org.apache.pig.impl.util.UDFContext;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-import junit.framework.TestCase;
-@RunWith(JUnit4.class)
-public class TestUDFContext extends TestCase {
+public class TestUDFContext {
static MiniCluster cluster = null;
- @Override
@Before
public void setUp() throws Exception {
cluster = MiniCluster.buildCluster();
@@ -87,4 +81,34 @@ public class TestUDFContext extends Test
assertEquals(tuple.get(3).toString(), "five");
}
}
+
+
+ /**
+ * Test that UDFContext is reset each time the plan is regenerated
+ * @throws Exception
+ */
+ @Test
+ public void testUDFContextReset() throws Exception {
+ PigServer pig = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
+ pig.registerQuery(" l = load 'file' as (a :int, b : int, c : int);");
+ pig.registerQuery(" f = foreach l generate a, b;");
+ pig.explain("f", System.out);
+ Properties props = UDFContext.getUDFContext().getUDFProperties(PigStorage.class);
+
+ // required fields property should be set because f results does not
+ // require the third column c, so properties should not be null
+ assertNotNull(props.get("l"));
+
+ // the new statement for alias f below will require all columns,
+ // so this time required fields property for loader should not be set
+ pig.registerQuery(" f = foreach l generate a, b, c;");
+ pig.explain("f", System.out);
+ props = UDFContext.getUDFContext().getUDFProperties(PigStorage.class);
+
+ assertTrue("properties in udf context for load should be null",
+ props.get("l") == null);
+
+
+ }
+
}