Review Board 1.7.22


PIG-3379: Alias reuse in nested foreach causes PIG script to fail

Review Request #13302 - Created Aug. 5, 2013 and updated

Xuefu Zhang
trunk
PIG-3379
Reviewers
pig
daijy, tejasp
pig-git
Review request for Pig-3379
Unit test passed. Test-commit passed.
src/org/apache/pig/newplan/logical/expression/ProjectExpression.java
Revision e330a0e New Change
[20] 49 lines
[+20] [+] public class ProjectExpression extends ColumnExpression {
50
                       // in a join, cross, cogroup, or union it could be
50
                       // in a join, cross, cogroup, or union it could be
51
                       // greater than 0.
51
                       // greater than 0.
52
    private int col; // The column in the input which the project references.
52
    private int col; // The column in the input which the project references.
53
                     // Count is zero based.
53
                     // Count is zero based.
54
    private String alias; // The alias of the projected field.
54
    private String alias; // The alias of the projected field.

    
   
55
    

    
   
56
    /**

    
   
57
     * In Foreach inner plan, a projection can be made on a relational operator, which may get reused.

    
   
58
     * However, the expression needs to be sticky to the operator on which the expression is projected.

    
   
59
     */

    
   
60
    private Operator projectedOperator;
55

    
   
61

   
56
    private LogicalRelationalOperator attachedRelationalOp;
62
    private LogicalRelationalOperator attachedRelationalOp;
57

    
   
63

   
58
    //fields for range projection.
64
    //fields for range projection.
59
    private boolean isRangeProject = false;
65
    private boolean isRangeProject = false;
[+20] [20] 29 lines
[+20] public class ProjectExpression extends ColumnExpression {
89
     * @param inputNum
95
     * @param inputNum
90
     * @param alias
96
     * @param alias
91
     * @param attachedRelationalOp
97
     * @param attachedRelationalOp
92
     * @throws FrontendException
98
     * @throws FrontendException
93
     */
99
     */
94
    public ProjectExpression(OperatorPlan plan, int inputNum, String alias,
100
    public ProjectExpression(OperatorPlan plan, int inputNum, String alias, Operator projectedOp,
95
            LogicalRelationalOperator attachedRelationalOp) {
101
            LogicalRelationalOperator attachedRelationalOp) {
96
        super("Project", plan);
102
        super("Project", plan);
97
        this.input = inputNum;
103
        this.input = inputNum;
98
        this.alias = alias;
104
        this.alias = alias;

    
   
105
        this.projectedOperator = projectedOp;
99
        plan.add(this);
106
        plan.add(this);
100
        this.attachedRelationalOp = attachedRelationalOp;
107
        this.attachedRelationalOp = attachedRelationalOp;
101
    }
108
    }
102

    
   
109

   
103
    /**
110
    /**
[+20] [20] 20 lines
[+20] public class ProjectExpression extends ColumnExpression {
124
    public ProjectExpression(ProjectExpression projExpr, OperatorPlan plan) {
131
    public ProjectExpression(ProjectExpression projExpr, OperatorPlan plan) {
125
        super("Project", plan);
132
        super("Project", plan);
126
        this.input = projExpr.input;
133
        this.input = projExpr.input;
127
        this.col = projExpr.col;
134
        this.col = projExpr.col;
128
        this.alias = projExpr.alias;
135
        this.alias = projExpr.alias;

    
   
136
        this.projectedOperator = projExpr.projectedOperator;
129
        this.attachedRelationalOp = projExpr.attachedRelationalOp;
137
        this.attachedRelationalOp = projExpr.attachedRelationalOp;
130
        this.isRangeProject = projExpr.isRangeProject;
138
        this.isRangeProject = projExpr.isRangeProject;
131
        this.startCol = projExpr.startCol;
139
        this.startCol = projExpr.startCol;
132
        this.endCol = projExpr.endCol;
140
        this.endCol = projExpr.endCol;
133
        this.startAlias = projExpr.startAlias;
141
        this.startAlias = projExpr.startAlias;
[+20] [20] 103 lines
[+20] [+] public int getColNum() {
237
    }
245
    }
238

    
   
246

   
239
    public String getColAlias() {
247
    public String getColAlias() {
240
        return alias;
248
        return alias;
241
    }
249
    }

    
   
250
    

    
   
251
    public Operator getProjectedOperator() {

    
   
252
    	return this.projectedOperator;

    
   
253
    }
242

    
   
254

   
243
    /**
255
    /**
244
     * Set the column number for this project.  This should only be called by
256
     * Set the column number for this project.  This should only be called by
245
     * ProjectionPatcher.  Stupid Java needs friends.
257
     * ProjectionPatcher.  Stupid Java needs friends.
246
     * @param colNum new column number for projection
258
     * @param colNum new column number for projection
[+20] [20] 287 lines
[+20] [+] public LogicalExpression deepCopy(LogicalExpressionPlan lgExpPlan) throws FrontendException {
534
                this.getInputNum(),
546
                this.getInputNum(),
535
                this.getColNum(),
547
                this.getColNum(),
536
                this.getAttachedRelationalOp());
548
                this.getAttachedRelationalOp());
537
        copy.setLocation( new SourceLocation( location ) );
549
        copy.setLocation( new SourceLocation( location ) );
538
        copy.alias = alias;
550
        copy.alias = alias;

    
   
551
        copy.projectedOperator = this.projectedOperator;
539
        copy.isRangeProject = this.isRangeProject;
552
        copy.isRangeProject = this.isRangeProject;
540
        copy.startCol = this.startCol;
553
        copy.startCol = this.startCol;
541
        copy.endCol = this.endCol;
554
        copy.endCol = this.endCol;
542
        copy.startAlias = this.startAlias;
555
        copy.startAlias = this.startAlias;
543
        copy.endAlias = this.endAlias;
556
        copy.endAlias = this.endAlias;
544

    
   
557

   
545
        return copy;
558
        return copy;
546
    }
559
    }
547

    
   
560

   
548
}
561
}
src/org/apache/pig/newplan/logical/relational/LOInnerLoad.java
Revision ad7c414 New Change
 
src/org/apache/pig/parser/LogicalPlanBuilder.java
Revision 99e481d New Change
 
src/org/apache/pig/parser/LogicalPlanGenerator.g
Revision cc1f47e New Change
 
test/org/apache/pig/test/TestEvalPipeline2.java
Revision 5680126 New Change
 
  1. src/org/apache/pig/newplan/logical/expression/ProjectExpression.java: Loading...
  2. src/org/apache/pig/newplan/logical/relational/LOInnerLoad.java: Loading...
  3. src/org/apache/pig/parser/LogicalPlanBuilder.java: Loading...
  4. src/org/apache/pig/parser/LogicalPlanGenerator.g: Loading...
  5. test/org/apache/pig/test/TestEvalPipeline2.java: Loading...