use of org.apache.drill.exec.planner.logical.FieldsReWriterUtil.DesiredField in project drill by apache.
the class DrillFilterItemStarReWriterRule method createFieldMapper.
/**
* Creates node mapper to replace item star calls with new input field references.
* Starting index should be calculated from the last used input expression (i.e. scan expression).
* NB: field reference index starts from 0 thus original field count can be taken as starting index
*
* @param desiredFields list of desired fields
* @param startingIndex starting index
* @return field mapper
*/
private static Map<RexNode, Integer> createFieldMapper(Collection<DesiredField> desiredFields, int startingIndex) {
Map<RexNode, Integer> fieldMapper = new HashMap<>();
int index = startingIndex;
for (DesiredField desiredField : desiredFields) {
for (RexNode node : desiredField.getNodes()) {
// if field is referenced in more then one call, add each call to field mapper
fieldMapper.put(node, index);
}
// increment index for the next node reference
index++;
}
return fieldMapper;
}
Aggregations