Program: 169077
Project: 169077
Buggy source:
/** 
 * Method that adds the appropriate returning fields to the elasticsearch query from those specified by the select clause
 * @param select SELECT clause including fields to be returned
 */
private void createSelect(Select select){
  if (null != select && null != select.getColumnMap() && !select.getColumnMap().isEmpty()) {
    Set<Selector> selectors=select.getColumnMap().keySet();
    if (isfucntion(selectors,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str")) {
      for (      Selector selector : selectors) {
        if (SelectorUtils.isFunction(selector,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str")) {
          FunctionSelector functionSelector=(FunctionSelector)selector;
          if (select.isDistinct() && isfucntion(selectors,"String_Node_Str")) {
            FunctionSelector function=(FunctionSelector)selector;
            Selector field=function.getFunctionColumns().getSelectorList().get(0);
            requestBuilder.addAggregation(AggregationBuilders.cardinality(function.getAlias()).field(SelectorUtils.getSelectorFieldName(field)));
          }
 else {
            requestBuilder.addAggregation(buildAggregation((FunctionSelector)selector,functionSelector.getFunctionName().toLowerCase().toString()));
          }
        }
      }
      requestBuilder.setSize(0);
      return;
    }
    for (    Selector selector : selectors) {
      String fieldName=SelectorUtils.getSelectorFieldName(selector);
      if (null != fieldName) {
        requestBuilder.addField(fieldName);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Method that adds the appropriate returning fields to the elasticsearch query from those specified by the select clause
 * @param select SELECT clause including fields to be returned
 */
private void createSelect(Select select){
  if (null != select && null != select.getColumnMap() && !select.getColumnMap().isEmpty()) {
    Set<Selector> selectors=select.getColumnMap().keySet();
    if (isFunction(selectors,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str")) {
      for (      Selector selector : selectors) {
        if (SelectorUtils.isFunction(selector,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str")) {
          FunctionSelector functionSelector=(FunctionSelector)selector;
          if (select.isDistinct() && isFunction(selectors,"String_Node_Str")) {
            FunctionSelector function=(FunctionSelector)selector;
            Selector field=function.getFunctionColumns().getSelectorList().get(0);
            requestBuilder.addAggregation(AggregationBuilders.cardinality(function.getAlias()).field(SelectorUtils.getSelectorFieldName(field)));
          }
 else {
            requestBuilder.addAggregation(buildAggregation((FunctionSelector)selector,functionSelector.getFunctionName().toLowerCase().toString()));
          }
        }
      }
      requestBuilder.setSize(0);
      return;
    }
    for (    Selector selector : selectors) {
      String fieldName=SelectorUtils.getSelectorFieldName(selector);
      if (null != fieldName) {
        requestBuilder.addField(fieldName);
      }
    }
  }
}