Review Board 1.7.22


Introduce a syntax making declared aliases optional

Review Request #9496 - Created Feb. 18, 2013 and updated

Jonathan Coveney
jcoveney/PIG3136
PIG-3136
Reviewers
pig
daijy, gates
pig-git
https://issues.apache.org/jira/browse/PIG-3136
ant -Dtestcase=TestBuiltin test, and ant test-commit

I made them TestBuiltin use it
src/org/apache/pig/PigServer.java
Revision a46cc2a New Change
[20] 193 lines
[+20] [+] private String constructScope() {
194
    }
194
    }
195

    
   
195

   
196
    public PigServer(ExecType execType, Properties properties) throws ExecException {
196
    public PigServer(ExecType execType, Properties properties) throws ExecException {
197
        this(new PigContext(execType, properties));
197
        this(new PigContext(execType, properties));
198
    }
198
    }
199
    
199

   
200
    public PigServer(ExecType execType, Configuration conf) throws ExecException {
200
    public PigServer(ExecType execType, Configuration conf) throws ExecException {
201
        this(new PigContext(execType, conf));
201
        this(new PigContext(execType, conf));
202
    }
202
    }
203

    
   
203

   
204
    public PigServer(PigContext context) throws ExecException {
204
    public PigServer(PigContext context) throws ExecException {
[+20] [20] 762 lines
[+20] [+] public ExecJob store(String id, String filename, String func)
967
        }
967
        }
968
    }
968
    }
969

    
   
969

   
970
    private PigStats storeEx(String alias, String filename, String func)
970
    private PigStats storeEx(String alias, String filename, String func)
971
    throws IOException {
971
    throws IOException {

    
   
972
        if ("@".equals(alias)) {

    
   
973
            alias = getLastRel();

    
   
974
        }
972
        currDAG.parseQuery();
975
        currDAG.parseQuery();
973
        currDAG.buildPlan( alias );
976
        currDAG.buildPlan( alias );
974

    
   
977

   
975
        try {
978
        try {
976
            QueryParserUtils.attachStorePlan(scope, currDAG.lp, filename, func, currDAG.getOperator( alias ), alias, pigContext);
979
            QueryParserUtils.attachStorePlan(scope, currDAG.lp, filename, func, currDAG.getOperator( alias ), alias, pigContext);
[+20] [20] 410 lines
[+20] [+] private LogicalRelationalOperator getOperatorForAlias(String alias) throws IOException {
1387
    protected class Graph {
1390
    protected class Graph {
1388

    
   
1391

   
1389
        private final Map<LogicalRelationalOperator, LogicalPlan> aliases = new HashMap<LogicalRelationalOperator, LogicalPlan>();
1392
        private final Map<LogicalRelationalOperator, LogicalPlan> aliases = new HashMap<LogicalRelationalOperator, LogicalPlan>();
1390

    
   
1393

   
1391
        private Map<String, Operator> operators = new HashMap<String, Operator>();
1394
        private Map<String, Operator> operators = new HashMap<String, Operator>();

    
   
1395
        private String lastRel;
1392

    
   
1396

   
1393
        private final List<String> scriptCache = new ArrayList<String>();
1397
        private final List<String> scriptCache = new ArrayList<String>();
1394

    
   
1398

   
1395
        // the fileNameMap contains filename to canonical filename
1399
        // the fileNameMap contains filename to canonical filename
1396
        // mappings. This is done so we can reparse the cached script
1400
        // mappings. This is done so we can reparse the cached script
[+20] [20] 250 lines
[+20] [+] private void parseQuery() throws FrontendException {
1647

    
   
1651

   
1648
            try {
1652
            try {
1649
                QueryParserDriver parserDriver = new QueryParserDriver( pigContext, scope, fileNameMap );
1653
                QueryParserDriver parserDriver = new QueryParserDriver( pigContext, scope, fileNameMap );
1650
                lp = parserDriver.parse( query );
1654
                lp = parserDriver.parse( query );
1651
                operators = parserDriver.getOperators();
1655
                operators = parserDriver.getOperators();

    
   
1656
                lastRel = parserDriver.getLastRel();
1652
            } catch(Exception ex) {
1657
            } catch(Exception ex) {
1653
                scriptCache.remove( scriptCache.size() -1 ); // remove the bad script from the cache.
1658
                scriptCache.remove( scriptCache.size() -1 ); // remove the bad script from the cache.
1654
                PigException pe = LogUtils.getPigException(ex);
1659
                PigException pe = LogUtils.getPigException(ex);
1655
                int errCode = 1000;
1660
                int errCode = 1000;
1656
                String msg = "Error during parsing. "
1661
                String msg = "Error during parsing. "
1657
                        + (pe == null ? ex.getMessage() : pe.getMessage());
1662
                        + (pe == null ? ex.getMessage() : pe.getMessage());
1658
                throw new FrontendException (msg, errCode, PigException.INPUT , ex );
1663
                throw new FrontendException (msg, errCode, PigException.INPUT , ex );
1659
            }
1664
            }
1660
        }
1665
        }
1661

    
   
1666

   

    
   
1667
        public String getLastRel() {

    
   
1668
            return lastRel;

    
   
1669
        }

    
   
1670

   
1662
        private String buildQuery() {
1671
        private String buildQuery() {
1663
            StringBuilder accuQuery = new StringBuilder();
1672
            StringBuilder accuQuery = new StringBuilder();
1664
            for( String line : scriptCache ) {
1673
            for( String line : scriptCache ) {
1665
                accuQuery.append( line + "\n" );
1674
                accuQuery.append( line + "\n" );
1666
            }
1675
            }
[+20] [20] 147 lines
[+20] [+] protected Graph duplicate() {
1814
     * @param validateEachStatement
1823
     * @param validateEachStatement
1815
     */
1824
     */
1816
    public void setValidateEachStatement(boolean validateEachStatement) {
1825
    public void setValidateEachStatement(boolean validateEachStatement) {
1817
        this.validateEachStatement = validateEachStatement;
1826
        this.validateEachStatement = validateEachStatement;
1818
    }
1827
    }

    
   
1828

   

    
   
1829
    public String getLastRel() {

    
   
1830
        return currDAG.getLastRel();

    
   
1831
    }
1819
}
1832
}
src/org/apache/pig/parser/LogicalPlanBuilder.java
Revision b705686 New Change
 
src/org/apache/pig/parser/LogicalPlanGenerator.g
Revision 01dc570 New Change
 
src/org/apache/pig/parser/QueryLexer.g
Revision bdd0836 New Change
 
src/org/apache/pig/parser/QueryParser.g
Revision ba2fec9 New Change
 
src/org/apache/pig/parser/QueryParserDriver.java
Revision a250b73 New Change
 
src/org/apache/pig/tools/grunt/GruntParser.java
Revision 2658466 New Change
 
src/org/apache/pig/tools/pigscript/parser/PigScriptParser.jj
Revision 109a3b2 New Change
 
test/org/apache/pig/test/TestBuiltin.java
Revision 9c5d408 New Change
 
  1. src/org/apache/pig/PigServer.java: Loading...
  2. src/org/apache/pig/parser/LogicalPlanBuilder.java: Loading...
  3. src/org/apache/pig/parser/LogicalPlanGenerator.g: Loading...
  4. src/org/apache/pig/parser/QueryLexer.g: Loading...
  5. src/org/apache/pig/parser/QueryParser.g: Loading...
  6. src/org/apache/pig/parser/QueryParserDriver.java: Loading...
  7. src/org/apache/pig/tools/grunt/GruntParser.java: Loading...
  8. src/org/apache/pig/tools/pigscript/parser/PigScriptParser.jj: Loading...
  9. test/org/apache/pig/test/TestBuiltin.java: Loading...