= cg.getGroupByPlans() ;
List<LogicalOperator> inputs = cg.getInputs() ;
// Type checking internal plans.
for(int i=0;i < inputs.size(); i++) {
LogicalOperator input = inputs.get(i) ;
List<LogicalPlan> innerPlans
= new ArrayList<LogicalPlan>(groupByPlans.get(input)) ;
for(int j=0; j < innerPlans.size(); j++) {
LogicalPlan innerPlan = innerPlans.get(j) ;
// Check that the inner plan has only 1 output port
if (!innerPlan.isSingleLeafPlan()) {
int errCode = 1057;
String msg = "COGroup's inner plans can only"
+ "have one output (leaf)" ;
msgCollector.collect(msg, MessageType.Error) ;
throw new TypeCheckerException(msg, errCode, PigException.INPUT) ;
}
checkInnerPlan(cg.getAlias(), innerPlans.get(j)) ;
}
}
try {
if (!cg.isTupleGroupCol()) {
// merge all the inner plan outputs so we know what type
// our group column should be
// TODO: Don't recompute schema here
//byte groupType = schema.getField(0).type ;
byte groupType = cg.getAtomicGroupByType() ;
// go through all inputs again to add cast if necessary
for(int i=0;i < inputs.size(); i++) {
LogicalOperator input = inputs.get(i) ;
List<LogicalPlan> innerPlans
= new ArrayList<LogicalPlan>(groupByPlans.get(input)) ;
// Checking innerPlan size already done above
byte innerType = innerPlans.get(0).getSingleLeafPlanOutputType() ;
if (innerType != groupType) {
insertAtomicCastForCOGroupInnerPlan(innerPlans.get(0),
cg,
groupType) ;
}
}
}
else {
// TODO: Don't recompute schema here
//Schema groupBySchema = schema.getField(0).schema ;
Schema groupBySchema = cg.getTupleGroupBySchema() ;
// go through all inputs again to add cast if necessary
for(int i=0;i < inputs.size(); i++) {
LogicalOperator input = inputs.get(i) ;
List<LogicalPlan> innerPlans
= new ArrayList<LogicalPlan>(groupByPlans.get(input)) ;
for(int j=0;j < innerPlans.size(); j++) {
LogicalPlan innerPlan = innerPlans.get(j) ;
byte innerType = innerPlan.getSingleLeafPlanOutputType() ;