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/03/08 21:34:11 UTC

svn commit: r1079521 - in /pig/trunk: src/org/apache/pig/ src/org/apache/pig/impl/ src/org/apache/pig/newplan/logical/visitor/ src/org/apache/pig/parser/ test/org/apache/pig/test/

Author: thejas
Date: Tue Mar  8 20:34:11 2011
New Revision: 1079521

URL: http://svn.apache.org/viewvc?rev=1079521&view=rev
Log:
PIG-1618: Switch to new parser generator technology - NewParser-22.patch (xuefuz via thejas )

Modified:
    pig/trunk/src/org/apache/pig/PigServer.java
    pig/trunk/src/org/apache/pig/impl/PigContext.java
    pig/trunk/src/org/apache/pig/newplan/logical/visitor/TypeCheckingRelVisitor.java
    pig/trunk/src/org/apache/pig/parser/AstValidator.g
    pig/trunk/src/org/apache/pig/parser/ParserException.java
    pig/trunk/src/org/apache/pig/parser/QueryLexer.g
    pig/trunk/src/org/apache/pig/parser/QueryParserDriver.java
    pig/trunk/test/org/apache/pig/test/TestBestFitCast.java
    pig/trunk/test/org/apache/pig/test/TestDataBagAccess.java
    pig/trunk/test/org/apache/pig/test/TestEvalPipeline2.java
    pig/trunk/test/org/apache/pig/test/TestLogToPhyCompiler.java
    pig/trunk/test/org/apache/pig/test/TestMergeJoin.java
    pig/trunk/test/org/apache/pig/test/TestScalarAliases.java

Modified: pig/trunk/src/org/apache/pig/PigServer.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/PigServer.java?rev=1079521&r1=1079520&r2=1079521&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/PigServer.java (original)
+++ pig/trunk/src/org/apache/pig/PigServer.java Tue Mar  8 20:34:11 2011
@@ -66,7 +66,6 @@ import org.apache.pig.impl.io.FileLocali
 import org.apache.pig.impl.logicalLayer.FrontendException;
 import org.apache.pig.impl.logicalLayer.schema.Schema;
 import org.apache.pig.impl.plan.CompilationMessageCollector;
-import org.apache.pig.impl.plan.OperatorKey;
 import org.apache.pig.impl.streaming.StreamingCommand;
 import org.apache.pig.impl.util.LogUtils;
 import org.apache.pig.impl.util.ObjectSerializer;
@@ -899,12 +898,12 @@ public class PigServer {
     private PigStats storeEx(String alias, String filename, String func)
     throws IOException {
         currDAG.parseQuery();
-        LogicalPlan lp = currDAG.buildPlan( alias );
+        currDAG.buildPlan( alias );
 
         try {
-            QueryParserUtils.attachStorePlan( lp, filename, func, currDAG.getOperator( alias ), alias, pigContext );
-            compileLp();
-            return executeCompiledLogicalPlan( lp );
+            QueryParserUtils.attachStorePlan( currDAG.lp, filename, func, currDAG.getOperator( alias ), alias, pigContext );
+            currDAG.compile();
+            return executeCompiledLogicalPlan();
         } catch (PigException e) {
             int errCode = 1002;
             String msg = "Unable to store alias " + alias;
@@ -950,16 +949,15 @@ public class PigServer {
                         PrintStream eps) throws IOException {
         try {
             pigContext.inExplain = true;
-            LogicalPlan lp = getStorePlan(alias);
-            compileLp();
-            if (lp.size() == 0) {
+            buildStorePlan( alias );
+            if( currDAG.lp.size() == 0 ) {
                 lps.println("Logical plan is empty.");
                 pps.println("Physical plan is empty.");
                 eps.println("Execution plan is empty.");
                 return;
             }
-            PhysicalPlan pp = compilePp(lp);
-            lp.explain(lps, format, verbose);
+            PhysicalPlan pp = compilePp();
+            currDAG.lp.explain(lps, format, verbose);
 
             HashSet<String> optimizerRules = null;
             try {
@@ -971,10 +969,10 @@ public class PigServer {
                 throw new FrontendException(msg, errCode, PigException.BUG, ioe);
             }
 
-            LogicalPlanOptimizer optimizer = new LogicalPlanOptimizer(lp, 3, optimizerRules);
+            LogicalPlanOptimizer optimizer = new LogicalPlanOptimizer( currDAG.lp, 3, optimizerRules );
             optimizer.optimize();
 
-            lp.explain(lps, format, verbose);
+            currDAG.lp.explain(lps, format, verbose);
 
             pp.explain(pps, format, verbose);
             pigContext.getExecutionEngine().explain(pp, eps, format, verbose);
@@ -1147,7 +1145,6 @@ public class PigServer {
     }
 
     public Map<Operator, DataBag> getExamples(String alias) throws IOException {
-        LogicalPlan plan = null;
         try {
             if (currDAG.isBatchOn() && alias != null) {
                 currDAG.parseQuery();
@@ -1156,7 +1153,7 @@ public class PigServer {
             }
             currDAG.parseQuery();
             currDAG.buildPlan( alias );
-            plan = compileLp();
+            currDAG.compile();
         } catch (IOException e) {
             //Since the original script is parsed anyway, there should not be an
             //error in this parsing. The only reason there can be an error is when
@@ -1164,7 +1161,7 @@ public class PigServer {
             e.printStackTrace();
         }
         
-        ExampleGenerator exgen = new ExampleGenerator(plan, pigContext);
+        ExampleGenerator exgen = new ExampleGenerator( currDAG.lp, pigContext );
         try {
             return exgen.getExamples();
         } catch (ExecException e) {
@@ -1177,17 +1174,17 @@ public class PigServer {
      
     }
 
-    private LogicalPlan getStorePlan(String alias) throws IOException {
+    private void buildStorePlan(String alias) throws IOException {
         currDAG.parseQuery();
-        LogicalPlan lp = currDAG.buildPlan( alias );
+        currDAG.buildPlan( alias );
 
         if( !isBatchOn() || alias != null ) {
             // MRCompiler needs a store to be the leaf - hence
             // add a store to the plan to explain
-            QueryParserUtils.attachStorePlan( lp, "fakefile", null, currDAG.getOperator( alias ), 
+            QueryParserUtils.attachStorePlan( currDAG.lp, "fakefile", null, currDAG.getOperator( alias ), 
                     "fake", pigContext );
         }
-        return lp;
+        currDAG.compile();
     }
 
     /**
@@ -1201,13 +1198,13 @@ public class PigServer {
             pigContext.getProperties().setProperty( PigContext.JOB_PRIORITY, jobPriority );
         }
         
-        LogicalPlan compiledLp = compileLp();
+       currDAG.compile();
 
-        if( compiledLp.size() == 0 ) {
+        if( currDAG.lp.size() == 0 ) {
             return PigStatsUtil.getEmptyPigStats();
         }
 
-        PigStats stats = executeCompiledLogicalPlan( compiledLp );
+        PigStats stats = executeCompiledLogicalPlan();
         
         // At this point, all stores in the plan are executed. They should be ignored if the plan is reused.
         currDAG.executed();
@@ -1215,10 +1212,10 @@ public class PigServer {
         return stats;
     }
 
-    private PigStats executeCompiledLogicalPlan(LogicalPlan compiledLp) throws ExecException, FrontendException {
+    private PigStats executeCompiledLogicalPlan() throws ExecException, FrontendException {
         // discover pig features used in this script
-        ScriptState.get().setScriptFeatures(compiledLp);
-        PhysicalPlan pp = compilePp(compiledLp);
+        ScriptState.get().setScriptFeatures( currDAG.lp );
+        PhysicalPlan pp = compilePp();
         // execute using appropriate engine
         List<ExecJob> jobs = pigContext.getExecutionEngine().execute(pp, "job_pigexec_");
         PigStats stats = null;
@@ -1241,26 +1238,6 @@ public class PigServer {
         return stats;
     }
 
-    private LogicalPlan compileLp() throws IOException {
-        LogicalPlan lp = currDAG.lp;
-        
-        new ColumnAliasConversionVisitor( lp ).visit();
-        new ProjectStarExpander(lp).visit();
-        new ScalarVisitor( lp, pigContext ).visit();
-        
-        // TODO: move optimizer here from HExecuteEngine.
-        // TODO: input/output validation visitor
-
-        CompilationMessageCollector collector = new CompilationMessageCollector() ;
-        new TypeCheckingRelVisitor( lp, collector).visit();
-        new UnionOnSchemaSetter( lp ).visit();
-        new CastLineageSetter(lp, collector).visit();
-        
-        currDAG.postProcess();
-        
-        return lp;
-    }
-    
     /**
      * NOTE: For testing only. Don't use.
      * @throws IOException
@@ -1268,12 +1245,13 @@ public class PigServer {
     @SuppressWarnings("unused")
     private LogicalPlan buildLp() throws IOException {
         currDAG.buildPlan( null);
-        return compileLp();
+        currDAG.compile();
+        return currDAG.lp;
     }
 
-    private PhysicalPlan compilePp(LogicalPlan lp) throws FrontendException {
+    private PhysicalPlan compilePp() throws FrontendException {
         // translate lp to physical plan
-        return pigContext.getExecutionEngine().compile(lp, null);
+        return pigContext.getExecutionEngine().compile( currDAG.lp, null );
     }
 
     private LogicalRelationalOperator getOperatorForAlias(String alias) throws IOException {
@@ -1284,7 +1262,7 @@ public class PigServer {
             String msg = "No plan for " + alias + " to describe";
             throw new FrontendException(msg, errCode, PigException.INPUT, false, null);
         }
-        compileLp();
+        currDAG.compile();
         return op;
     }
 
@@ -1363,7 +1341,7 @@ public class PigServer {
          * will be ignored. Dependent branch (i.e. scalar) will be kept.
          * @throws IOException 
          */
-        LogicalPlan buildPlan(String alias) throws IOException {
+        void buildPlan(String alias) throws IOException {
             if( alias == null )
                 skipStores();
             
@@ -1421,7 +1399,7 @@ public class PigServer {
                 
                 currOp.setPlan( plan );
             }
-            return lp = plan;
+            lp = plan;
         }
         
         /**
@@ -1454,6 +1432,10 @@ public class PigServer {
          * an overall (raw) plan.
          */
         void registerQuery(String query, int startLine) throws IOException {
+            if( !batchMode ) {
+                validateQuery( query );
+            }
+            
             scriptCache.add( query );
             parseQuery();
             
@@ -1475,29 +1457,35 @@ public class PigServer {
                 }
             }
         }
+        
+        void validateQuery(String q) throws FrontendException {
+            String query = buildQuery() + "\n" + q;
+            if( query.isEmpty() ) {
+                return;
+            }
+
+            QueryParserDriver parserDriver = new QueryParserDriver( pigContext, scope, fileNameMap );
+            LogicalPlan plan = parserDriver.parse( query );
+            compile( plan );
+        }
 
         /**
          * Parse the accumulated pig statements and generate an overall plan.
          */
-        private void parseQuery() throws IOException {
+        private void parseQuery() throws FrontendException {
             UDFContext.getUDFContext().reset();
-            StringBuilder accuQuery = new StringBuilder();
-            for( String line : scriptCache ) {
-                accuQuery.append( line + "\n" );
-            }
-            
-            String query = accuQuery.toString();
-            query = query.trim();
+            String query = buildQuery();
 
             if( query.isEmpty() ) {
                 lp = new LogicalPlan();
+                return;
             }
 
             try {
                 QueryParserDriver parserDriver = new QueryParserDriver( pigContext, scope, fileNameMap );
                 lp = parserDriver.parse( query );
                 operators = parserDriver.getOperators();
-            } catch(ParserException ex) {
+            } catch(Exception ex) {
                 scriptCache.remove( scriptCache.size() -1 ); // remove the bad script from the cache.
                 PigException pe = LogUtils.getPigException(ex);
                 int errCode = 1000;
@@ -1506,7 +1494,37 @@ public class PigServer {
                 throw new FrontendException (msg, errCode, PigException.INPUT );
             }
         }
+
+        private String buildQuery() {
+            StringBuilder accuQuery = new StringBuilder();
+            for( String line : scriptCache ) {
+                accuQuery.append( line + "\n" );
+            }
+            
+            String query = accuQuery.toString();
+            query = query.trim();
+            return query;
+        }
+        
+        private void compile() throws IOException {
+            compile( lp );
+            currDAG.postProcess();
+        }
         
+        private void compile(LogicalPlan lp) throws FrontendException  {
+            new ColumnAliasConversionVisitor( lp ).visit();
+            new ProjectStarExpander(lp).visit();
+            new ScalarVisitor( lp, pigContext ).visit();
+            
+            // TODO: move optimizer here from HExecuteEngine.
+            // TODO: input/output validation visitor
+
+            CompilationMessageCollector collector = new CompilationMessageCollector() ;
+            new TypeCheckingRelVisitor( lp, collector).visit();
+            new UnionOnSchemaSetter( lp ).visit();
+            new CastLineageSetter(lp, collector).visit();
+        }
+
         private void postProcess() throws IOException {
 
             // The following code deals with store/load combination of

Modified: pig/trunk/src/org/apache/pig/impl/PigContext.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/impl/PigContext.java?rev=1079521&r1=1079520&r2=1079521&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/impl/PigContext.java (original)
+++ pig/trunk/src/org/apache/pig/impl/PigContext.java Tue Mar  8 20:34:11 2011
@@ -459,7 +459,7 @@ public class PigContext implements Seria
             objClass = resolveClassName(className);
         }
         catch(IOException ioe) {
-            throw new RuntimeException("Cannot instantiate:" + className, ioe) ;
+            throw new RuntimeException("Cannot instantiate: " + className, ioe) ;
         }
 
         try {

Modified: pig/trunk/src/org/apache/pig/newplan/logical/visitor/TypeCheckingRelVisitor.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/newplan/logical/visitor/TypeCheckingRelVisitor.java?rev=1079521&r1=1079520&r2=1079521&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/newplan/logical/visitor/TypeCheckingRelVisitor.java (original)
+++ pig/trunk/src/org/apache/pig/newplan/logical/visitor/TypeCheckingRelVisitor.java Tue Mar  8 20:34:11 2011
@@ -169,7 +169,7 @@ public class TypeCheckingRelVisitor exte
             forEach.getSchema() ;
         }  catch (FrontendException fe) {
             int errCode = 1059;
-            String msg = "Problem while reconciling output schema of Filter" ;
+            String msg = "Problem while reconciling output schema of ForEach" ;
             msgCollector.collect(msg, MessageType.Error);
             throw new TypeCheckerException(msg, errCode, PigException.INPUT, fe) ;
         }

Modified: pig/trunk/src/org/apache/pig/parser/AstValidator.g
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/parser/AstValidator.g?rev=1079521&r1=1079520&r2=1079521&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/parser/AstValidator.g (original)
+++ pig/trunk/src/org/apache/pig/parser/AstValidator.g Tue Mar  8 20:34:11 2011
@@ -107,7 +107,6 @@ statement : general_statement
 split_statement : split_clause
 ;
 
-// For foreach statement that with complex inner plan.
 general_statement : ^( STATEMENT ( alias { aliases.add( $alias.name ); } )? op_clause parallel_clause? )
 ;
 

Modified: pig/trunk/src/org/apache/pig/parser/ParserException.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/parser/ParserException.java?rev=1079521&r1=1079520&r2=1079521&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/parser/ParserException.java (original)
+++ pig/trunk/src/org/apache/pig/parser/ParserException.java Tue Mar  8 20:34:11 2011
@@ -19,9 +19,10 @@
 package org.apache.pig.parser;
 
 import org.antlr.runtime.RecognitionException;
+import org.apache.pig.impl.logicalLayer.FrontendException;
 
 
-public class ParserException extends Exception {
+public class ParserException extends FrontendException {
 	private static final long serialVersionUID = 1L;
 	
 	public ParserException(RecognitionException recoException) {
@@ -34,6 +35,6 @@ public class ParserException extends Exc
 	
 	@Override
 	public String toString() {
-		return "Failed to parser: " +  getMessage();
+		return "Failed to parse: " +  getMessage();
 	}
 }

Modified: pig/trunk/src/org/apache/pig/parser/QueryLexer.g
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/parser/QueryLexer.g?rev=1079521&r1=1079520&r2=1079521&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/parser/QueryLexer.g (original)
+++ pig/trunk/src/org/apache/pig/parser/QueryLexer.g Tue Mar  8 20:34:11 2011
@@ -27,8 +27,18 @@ package org.apache.pig.parser;
 }
 
 @members {
+
+@Override
+public void reportError(RecognitionException e) {
+    super.reportError( e );
+    // The method of this signature doesn't permit checked exception. Here we have to 
+    // throw a unchecked execption in order to stop at the first error.
+    // For more information, visit http://www.antlr.org/wiki/pages/viewpage.action?pageId=5341217.
+    throw new RuntimeException( e );
 }
 
+} // End of members.
+
 DEFINE : 'DEFINE'
 ;
 

Modified: pig/trunk/src/org/apache/pig/parser/QueryParserDriver.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/parser/QueryParserDriver.java?rev=1079521&r1=1079520&r2=1079521&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/parser/QueryParserDriver.java (original)
+++ pig/trunk/src/org/apache/pig/parser/QueryParserDriver.java Tue Mar  8 20:34:11 2011
@@ -45,7 +45,7 @@ public class QueryParserDriver {
         this.fileNameMap = fileNameMap;
     }
 
-    public LogicalPlan parse(String query) throws IOException, ParserException {
+    public LogicalPlan parse(String query) throws ParserException {
         LogicalPlan plan = null;
         
         try {
@@ -65,6 +65,8 @@ public class QueryParserDriver {
             operators = planGenerator.getOperators();
         } catch(RecognitionException ex) {
             throw new ParserException( ex );
+        } catch(Exception ex) {
+            throw new ParserException( "Unexpected exception: " + ex.getMessage() );
         }
         
         return plan;

Modified: pig/trunk/test/org/apache/pig/test/TestBestFitCast.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestBestFitCast.java?rev=1079521&r1=1079520&r2=1079521&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestBestFitCast.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestBestFitCast.java Tue Mar  8 20:34:11 2011
@@ -217,9 +217,9 @@ public class TestBestFitCast {
         //Passing (float, bytearray)
         //Ambiguous matches: (float, long) , (float, double)
         boolean exceptionCaused = false;
-        pigServer.registerQuery("A = LOAD '" + inputFile + "' as (x:float, y);");
-        pigServer.registerQuery("B = FOREACH A generate x, " + UDF3.class.getName() + "(x,y);");
         try {
+            pigServer.registerQuery("A = LOAD '" + inputFile + "' as (x:float, y);");
+            pigServer.registerQuery("B = FOREACH A generate x, " + UDF3.class.getName() + "(x,y);");
             Iterator<Tuple> iter = pigServer.openIterator("B");
         } catch(Exception e) {
             exceptionCaused = true;
@@ -302,9 +302,9 @@ public class TestBestFitCast {
         // bytearray can be casted to float but the two ints cannot be unambiguously
         // casted
         boolean exceptionCaused = false;
-        pigServer.registerQuery("A = LOAD '" + inputFile + "' as (x, y:int);");
-        pigServer.registerQuery("B = FOREACH A generate x, " + UDF3.class.getName() + "(x,y, y);");
         try {
+            pigServer.registerQuery("A = LOAD '" + inputFile + "' as (x, y:int);");
+            pigServer.registerQuery("B = FOREACH A generate x, " + UDF3.class.getName() + "(x,y, y);");
             Iterator<Tuple> iter = pigServer.openIterator("B");
         }catch(Exception e) {
             exceptionCaused = true;
@@ -323,9 +323,9 @@ public class TestBestFitCast {
         // bytearray can be casted to float but the two longs cannot be
         // unambiguously casted
         boolean exceptionCaused = false;
-        pigServer.registerQuery("A = LOAD '" + inputFile + "' as (x, y:long);");
-        pigServer.registerQuery("B = FOREACH A generate x, " + UDF3.class.getName() + "(x,y, y);");
         try {
+            pigServer.registerQuery("A = LOAD '" + inputFile + "' as (x, y:long);");
+            pigServer.registerQuery("B = FOREACH A generate x, " + UDF3.class.getName() + "(x,y, y);");
             Iterator<Tuple> iter = pigServer.openIterator("B");
         }catch(Exception e) {
             exceptionCaused = true;
@@ -344,9 +344,9 @@ public class TestBestFitCast {
         // bytearray can be casted to float but the two doubles cannot be 
         // casted with a permissible cast
         boolean exceptionCaused = false;
-        pigServer.registerQuery("A = LOAD '" + inputFile + "' as (x, y:double);");
-        pigServer.registerQuery("B = FOREACH A generate x, " + UDF3.class.getName() + "(x,y, y);");
         try {
+            pigServer.registerQuery("A = LOAD '" + inputFile + "' as (x, y:double);");
+            pigServer.registerQuery("B = FOREACH A generate x, " + UDF3.class.getName() + "(x,y, y);");
             Iterator<Tuple> iter = pigServer.openIterator("B");
         }catch(Exception e) {
             exceptionCaused = true;
@@ -456,9 +456,9 @@ public class TestBestFitCast {
         // will cause conflict since we could cast int to 
         // long or double and bytearray to long or double.
         boolean exceptionCaused = false;
-        pigServer.registerQuery("A = LOAD '" + inputFile2 + "' as (x:float, y, z:int);");
-        pigServer.registerQuery("B = FOREACH A generate x, " + UDF3.class.getName() + "(x,y, y);");
         try {
+            pigServer.registerQuery("A = LOAD '" + inputFile2 + "' as (x:float, y, z:int);");
+            pigServer.registerQuery("B = FOREACH A generate x, " + UDF3.class.getName() + "(x,y, y);");
             Iterator<Tuple> iter = pigServer.openIterator("B");
         }catch(Exception e) {
             exceptionCaused = true;
@@ -633,9 +633,9 @@ public class TestBestFitCast {
         //Passing (int, int)
         //Possible matches: (float, float) , (long, double)
         //Throws Exception as ambiguous definitions found
-        pigServer.registerQuery("A = LOAD '" + inputFile + "' as (x:long, y:int);");
-        pigServer.registerQuery("B = FOREACH A generate x, " + UDF1.class.getName() + "(y,y);");
         try{
+            pigServer.registerQuery("A = LOAD '" + inputFile + "' as (x:long, y:int);");
+            pigServer.registerQuery("B = FOREACH A generate x, " + UDF1.class.getName() + "(y,y);");
             pigServer.openIterator("B");
         }catch (Exception e) {
             PigException pe = LogUtils.getPigException(e);
@@ -687,9 +687,9 @@ public class TestBestFitCast {
         //Passing bytearrays
         //Possible matches: (float, float) , (long, double)
         //Throws exception since more than one funcSpec and inp is bytearray
-        pigServer.registerQuery("A = LOAD '" + inputFile + "';");
-        pigServer.registerQuery("B = FOREACH A generate $0, " + UDF1.class.getName() + "($1,$1);");
         try{
+            pigServer.registerQuery("A = LOAD '" + inputFile + "';");
+            pigServer.registerQuery("B = FOREACH A generate $0, " + UDF1.class.getName() + "($1,$1);");
             pigServer.openIterator("B");
         }catch (Exception e) {
             PigException pe = LogUtils.getPigException(e);

Modified: pig/trunk/test/org/apache/pig/test/TestDataBagAccess.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestDataBagAccess.java?rev=1079521&r1=1079520&r2=1079521&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestDataBagAccess.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestDataBagAccess.java Tue Mar  8 20:34:11 2011
@@ -119,17 +119,16 @@ public class TestDataBagAccess extends T
     public void testBagConstantAccessFailure() throws IOException, ExecException {
         File input = Util.createInputFile("tmp", "", 
                 new String[] {"sampledata\tnot_used"});
-        pigServer.registerQuery("a = load '" 
-                + Util.generateURI(Util.encodeEscape(input.toString()), pigServer.getPigContext()) + "';");
-        pigServer.registerQuery("b = foreach a generate {(16, 4.0e-2, 'hello')} as mybag:{t:(i: int, d: double, c: chararray)};");
         boolean exceptionOccured = false;
         try {
+            pigServer.registerQuery("a = load '" 
+                    + Util.generateURI(Util.encodeEscape(input.toString()), pigServer.getPigContext()) + "';");
+            pigServer.registerQuery("b = foreach a generate {(16, 4.0e-2, 'hello')} as mybag:{t:(i: int, d: double, c: chararray)};");
             pigServer.registerQuery("c = foreach b generate mybag.t;");
             pigServer.explain("c", System.out);
         } catch(FrontendException e) {
             exceptionOccured = true;
-            Throwable cause = e.getCause();
-            String msg = cause.getMessage();
+            String msg = e.getMessage();
             Util.checkStrContainsSubStr(msg, "Invalid field reference. Referenced field [t] does not exist in schema");
         }
         assertTrue(exceptionOccured);

Modified: pig/trunk/test/org/apache/pig/test/TestEvalPipeline2.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestEvalPipeline2.java?rev=1079521&r1=1079520&r2=1079521&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestEvalPipeline2.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestEvalPipeline2.java Tue Mar  8 20:34:11 2011
@@ -502,18 +502,15 @@ public class TestEvalPipeline2 {
         };
         Util.createInputFile(cluster, "table_testCustomPartitionerParseJoins", input);
         
-        pigServer.registerQuery("A = LOAD 'table_testCustomPartitionerParseJoins' as (a0:int, a1:int);");
-        
-        pigServer.registerQuery("B = ORDER A by $0;");
-        
         // Custom Partitioner is not allowed for skewed joins, will throw a ExecException 
         try {
+            pigServer.registerQuery("A = LOAD 'table_testCustomPartitionerParseJoins' as (a0:int, a1:int);");
+            pigServer.registerQuery("B = ORDER A by $0;");
         	pigServer.registerQuery("skewed = JOIN A by $0, B by $0 USING 'skewed' PARTITION BY org.apache.pig.test.utils.SimpleCustomPartitioner;");
         	//control should not reach here
         	Assert.fail("Skewed join cannot accept a custom partitioner");
-        }
-        catch (FrontendException e) {
-        	Assert.assertTrue(e.getErrorCode() == 1000);
+        } catch(FrontendException e) {
+        	Assert.assertTrue( e.getMessage().contains( "Custom Partitioner is not supported for skewed join" ) );
 		}
         
         pigServer.registerQuery("hash = JOIN A by $0, B by $0 USING 'hash' PARTITION BY org.apache.pig.test.utils.SimpleCustomPartitioner;");
@@ -892,11 +889,10 @@ public class TestEvalPipeline2 {
     // See PIG-1737
     @Test
     public void testMergeSchemaErrorMessage() throws IOException {
-        pigServer.registerQuery("a = load '1.txt' as (a0, a1, a2);");
-        pigServer.registerQuery("b = group a by (a0, a1);");
-        pigServer.registerQuery("c = foreach b generate flatten(group) as c0;");
-        
         try {
+            pigServer.registerQuery("a = load '1.txt' as (a0, a1, a2);");
+            pigServer.registerQuery("b = group a by (a0, a1);");
+            pigServer.registerQuery("c = foreach b generate flatten(group) as c0;");
             pigServer.openIterator("c");
         } catch (Exception e) {
             PigException pe = LogUtils.getPigException(e);
@@ -1217,12 +1213,11 @@ public class TestEvalPipeline2 {
     
     // See PIG-1785
     @Test
-    public void testAddingTwoBag() throws Exception{
-        pigServer.registerQuery("a = load '1.txt' as (name:chararray, age:int, gpa:double);");
-        pigServer.registerQuery("b = group a by name;");
-        pigServer.registerQuery("c = foreach b generate group, SUM(a.age*a.gpa);");
-        
+    public void testAddingTwoBag() {
         try {
+            pigServer.registerQuery("a = load '1.txt' as (name:chararray, age:int, gpa:double);");
+            pigServer.registerQuery("b = group a by name;");
+            pigServer.registerQuery("c = foreach b generate group, SUM(a.age*a.gpa);");
             pigServer.openIterator("c");
         } catch (Exception e) {
             PigException pe = LogUtils.getPigException(e);

Modified: pig/trunk/test/org/apache/pig/test/TestLogToPhyCompiler.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestLogToPhyCompiler.java?rev=1079521&r1=1079520&r2=1079521&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestLogToPhyCompiler.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestLogToPhyCompiler.java Tue Mar  8 20:34:11 2011
@@ -713,13 +713,10 @@ public class TestLogToPhyCompiler extend
         buildLp.setAccessible(true);
         org.apache.pig.newplan.logical.relational.LogicalPlan lp = (org.apache.pig.newplan.logical.relational.LogicalPlan ) buildLp.invoke( myPig );
 
-        java.lang.reflect.Method compilePp = myPig.getClass()
-            .getDeclaredMethod("compilePp",
-            new Class[] { org.apache.pig.newplan.logical.relational.LogicalPlan.class });
-        
+        java.lang.reflect.Method compilePp = myPig.getClass().getDeclaredMethod("compilePp");
         compilePp.setAccessible(true);
         
-        PhysicalPlan pp = (PhysicalPlan) compilePp.invoke(myPig, new Object[] { lp });
+        PhysicalPlan pp = (PhysicalPlan) compilePp.invoke(myPig);
         SortInfo si0 = ((POStore)(pp.getLeaves().get(0))).getSortInfo();
         SortInfo si1 = ((POStore)(pp.getLeaves().get(1))).getSortInfo();
         SortInfo expected = getSortInfo(

Modified: pig/trunk/test/org/apache/pig/test/TestMergeJoin.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestMergeJoin.java?rev=1079521&r1=1079520&r2=1079521&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestMergeJoin.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestMergeJoin.java Tue Mar  8 20:34:11 2011
@@ -384,14 +384,14 @@ public class TestMergeJoin {
 
     @Test
     public void testMergeJoin3Way() throws IOException{
-        pigServer.registerQuery("A = LOAD '" + INPUT_FILE + "' as (id, name, n);");
-        pigServer.registerQuery("B = LOAD '" + INPUT_FILE + "' as (id, name);");
-        pigServer.registerQuery("C = LOAD '" + INPUT_FILE + "' as (id, name);");
         try {
+            pigServer.registerQuery("A = LOAD '" + INPUT_FILE + "' as (id, name, n);");
+            pigServer.registerQuery("B = LOAD '" + INPUT_FILE + "' as (id, name);");
+            pigServer.registerQuery("C = LOAD '" + INPUT_FILE + "' as (id, name);");
             pigServer.registerQuery("D = join A by id, B by id, C by id using 'merge';");
         }catch(Exception e) {
             PigException pe = LogUtils.getPigException(e);
-            Assert.assertEquals(1000,pe.getErrorCode());
+            Assert.assertTrue( pe.getMessage().contains( "Merge join can only be applied for 2-way joins" ) );
             return;
         }
         Assert.fail("Should throw exception, do not support 3 way join");

Modified: pig/trunk/test/org/apache/pig/test/TestScalarAliases.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestScalarAliases.java?rev=1079521&r1=1079520&r2=1079521&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestScalarAliases.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestScalarAliases.java Tue Mar  8 20:34:11 2011
@@ -525,18 +525,18 @@ public class TestScalarAliases  {
         };
 
         Util.createLocalInputFile( "table_testScalarAliasesGrammar", input);
-        pigServer.registerQuery("A = LOAD 'table_testScalarAliasesGrammar' as (a0: long, a1: double);");
-        pigServer.registerQuery("B = group A all;");
-        pigServer.registerQuery("C = foreach B generate COUNT(A);");
 
         try {
+            pigServer.registerQuery("A = LOAD 'table_testScalarAliasesGrammar' as (a0: long, a1: double);");
+            pigServer.registerQuery("B = group A all;");
+            pigServer.registerQuery("C = foreach B generate COUNT(A);");
             // Only projections of C are supported 
             pigServer.registerQuery("Y = foreach A generate C;");
             pigServer.openIterator( "Y" );
             //Control should not reach here
             fail("Scalar projections are only supported");
         } catch (IOException pe){
-            assertTrue(pe.getMessage().equalsIgnoreCase("Error during parsing. Invalid scalar projection: C"));
+            assertTrue(pe.getMessage().contains("Invalid scalar projection: C"));
         }
     }