pig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r771495 - in /hadoop/pig/trunk: CHANGES.txt src/org/apache/pig/PigServer.java test/org/apache/pig/test/TestGrunt.java
Date Mon, 04 May 2009 23:23:20 GMT
Author: gates
Date: Mon May  4 23:23:20 2009
New Revision: 771495

URL: http://svn.apache.org/viewvc?rev=771495&view=rev
Log:
PIG-789: Fix dump and illustrate to work with new multi-query feature.


Modified:
    hadoop/pig/trunk/CHANGES.txt
    hadoop/pig/trunk/src/org/apache/pig/PigServer.java
    hadoop/pig/trunk/test/org/apache/pig/test/TestGrunt.java

Modified: hadoop/pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/CHANGES.txt?rev=771495&r1=771494&r2=771495&view=diff
==============================================================================
--- hadoop/pig/trunk/CHANGES.txt (original)
+++ hadoop/pig/trunk/CHANGES.txt Mon May  4 23:23:20 2009
@@ -55,7 +55,11 @@
 PIG-514: COUNT returns no results as a result of two filter statements in
 FOREACH (pradeepkth)
 
-Release 0.2.0 - Unreleased
+PIG-789: Fix dump and illustrate to work with new multi-query feature 
+(hagleitn via gates).
+
+
+Release 0.2.0
 
 INCOMPATIBLE CHANGES
 

Modified: hadoop/pig/trunk/src/org/apache/pig/PigServer.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/PigServer.java?rev=771495&r1=771494&r2=771495&view=diff
==============================================================================
--- hadoop/pig/trunk/src/org/apache/pig/PigServer.java (original)
+++ hadoop/pig/trunk/src/org/apache/pig/PigServer.java Mon May  4 23:23:20 2009
@@ -445,6 +445,9 @@
                 throw new FrontendException(msg, errCode, PigException.INPUT);
             }
 
+            if (currDAG.isBatchOn()) {
+                currDAG.execute();
+            }
             ExecJob job = store(id, FileLocalizer.getTemporaryPath(null, pigContext).toString(),
BinStorage.class.getName() + "()");
             
             // invocation of "execute" is synchronous!
@@ -475,32 +478,18 @@
         
     /**
      *  forces execution of query (and all queries from which it reads), in order to store
result in file
-     */
+     */        
     public ExecJob store(
             String id,
             String filename,
-            String func) throws IOException{
+            String func) throws IOException {
+
         if (!currDAG.getAliasOp().containsKey(id))
             throw new IOException("Invalid alias: " + id);
-        
-        try {
-            LogicalPlan readFrom = getPlanFromAlias(id, "store");
-            return store(id, readFrom, filename, func);
-        } catch (FrontendException fe) {
-            int errCode = 1002;
-            String msg = "Unable to store alias " + id;
-            throw new FrontendException(msg, errCode, PigException.INPUT, fe);
-        }
-    }
-        
-    public ExecJob store(
-            String id,
-            LogicalPlan readFrom,
-            String filename,
-            String func) throws IOException {
+
         try {
             LogicalPlan lp = compileLp(id);
-            
+
             // MRCompiler needs a store to be the leaf - hence
             // add a store to the plan to explain
             
@@ -701,7 +690,12 @@
 
     public Map<LogicalOperator, DataBag> getExamples(String alias) {
         LogicalPlan plan = null;
-        try {
+
+        try {        
+            if (currDAG.isBatchOn()) {
+                currDAG.execute();
+            }
+            
             plan = clonePlan(alias);
         } catch (IOException e) {
             //Since the original script is parsed anyway, there should not be an

Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestGrunt.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestGrunt.java?rev=771495&r1=771494&r2=771495&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestGrunt.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestGrunt.java Mon May  4 23:23:20 2009
@@ -543,4 +543,50 @@
     
         grunt.exec();
     }
+    
+    @Test
+    public void testDump() throws Throwable {
+        PigServer server = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
+        PigContext context = server.getPigContext();
+        
+        String strCmd = 
+            "rmf bla;"
+            +"a = load 'file:test/org/apache/pig/test/data/passwd';"
+            +"e = group a by $0;"
+            +"f = foreach e generate group, COUNT($1);"
+            +"store f into 'bla';"
+            +"f1 = load 'bla';"
+            +"g = order f1 by $1;"
+            +"dump g;";
+
+        ByteArrayInputStream cmd = new ByteArrayInputStream(strCmd.getBytes());
+        InputStreamReader reader = new InputStreamReader(cmd);
+        
+        Grunt grunt = new Grunt(new BufferedReader(reader), context);
+    
+        grunt.exec();
+    }
+
+    @Test
+    public void testIllustrate() throws Throwable {
+        PigServer server = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
+        PigContext context = server.getPigContext();
+        
+        String strCmd = 
+            "rmf bla;"
+            +"a = load 'file:test/org/apache/pig/test/data/passwd';"
+            +"e = group a by $0;"
+            +"f = foreach e generate group, COUNT($1);"
+            +"store f into 'bla';"
+            +"f1 = load 'bla' as (f:chararray);"
+            +"g = order f1 by $1;"
+            +"illustrate g;";
+
+        ByteArrayInputStream cmd = new ByteArrayInputStream(strCmd.getBytes());
+        InputStreamReader reader = new InputStreamReader(cmd);
+        
+        Grunt grunt = new Grunt(new BufferedReader(reader), context);
+    
+        grunt.exec();
+    }
 }



Mime
View raw message