List<Operator> srcs = exp.getSinks();
for (Operator src : srcs) {
if (src instanceof ProjectExpression) {
List<LOInnerLoad> innerLoads = LOForEach.findReacheableInnerLoadFromBoundaryProject((ProjectExpression)src).first;
for (LOInnerLoad innerLoad : innerLoads) {
ProjectExpression prj = innerLoad.getProjection();
if (prj.isProjectStar()) {
if (prj.findReferent().getSchema()!=null) {
for (LogicalSchema.LogicalFieldSchema fs : prj.findReferent().getSchema().getFields()) {
input.add(fs.uid);
}
}
}
else {
if (prj.findReferent().getSchema()!=null) {
LogicalSchema.LogicalFieldSchema fs = prj.findReferent().getSchema().getField(prj.getColNum());
input.add(fs.uid);
}
}
}
}
}
}
}
}
// for the flatten bag, we need to make sure at least one field is in the input
for(int i=0; i<ll.size(); i++) {
if (!gen.getFlattenFlags()[i]) {
continue;
}
LogicalExpressionPlan exp = ll.get(i);
LogicalExpression sink = (LogicalExpression)exp.getSources().get(0);
if (sink.getFieldSchema().type!=DataType.TUPLE && sink.getFieldSchema().type!=DataType.BAG)
continue;
List<Operator> srcs = exp.getSinks();
for (Operator src : srcs) {
if (!(src instanceof ProjectExpression))
continue;
List<LOInnerLoad> innerLoads = LOForEach.findReacheableInnerLoadFromBoundaryProject((ProjectExpression)src).first;
for (LOInnerLoad innerLoad : innerLoads) {
ProjectExpression prj = innerLoad.getProjection();
if (prj.isProjectStar()) {
if (prj.findReferent().getSchema()!=null) {
for (LogicalSchema.LogicalFieldSchema fs : prj.findReferent().getSchema().getFields()) {
input.add(fs.uid);
}
}
}
else {
if (prj.findReferent().getSchema()!=null) {
LogicalSchema.LogicalFieldSchema fs = prj.findReferent().getSchema().getField(prj.getColNum());
input.add(fs.uid);
}
}
}
}