Program: 31380
Project: 31380
Buggy source:
@SuppressFBWarnings("String_Node_Str") private RecordSource selectColumns0(final RecordSource recordSource,QueryModel model) throws ParserException {
  final ObjList<QueryColumn> columns=model.getColumns();
  final CharSequenceIntHashMap columnNameHistogram=model.getColumnNameHistogram();
  final RecordMetadata meta=recordSource.getMetadata();
  this.outerVirtualColumns.clear();
  this.aggregators.clear();
  this.selectedColumns.clear();
  this.selectedColumnAliases.clear();
  this.groupKeyColumns.clear();
  this.aggregateColumnSequence=0;
  ObjList<VirtualColumn> virtualColumns=null;
  for (int i=0, k=columns.size(); i < k; i++) {
    final QueryColumn qc=columns.getQuick(i);
    final ExprNode node=qc.getAst();
    if (node.type == ExprNode.NodeType.LITERAL) {
      if (meta.getColumnIndexQuiet(node.token) == -1) {
        throw QueryError.invalidColumn(node.position,node.token);
      }
      if (columnNameHistogram.get(node.token) > 0) {
        throw QueryError.$(node.position,"String_Node_Str");
      }
      selectedColumns.add(node.token);
      addAlias(node.position,qc.getAlias() == null ? node.token : qc.getAlias());
      groupKeyColumns.add(node.token);
      continue;
    }
    if (qc.getAlias() == null) {
      qc.of(createAlias(aggregateColumnSequence++),node);
    }
    selectedColumns.add(qc.getAlias());
    addAlias(node.position,qc.getAlias());
    if (node.type == ExprNode.NodeType.FUNCTION && FunctionFactories.isAggregate(node.token)) {
      aggregators.add(qc);
      continue;
    }
    if (node.type == ExprNode.NodeType.OPERATION || node.type == ExprNode.NodeType.FUNCTION) {
      int beforeSplit=aggregators.size();
      splitAggregates(node,aggregators);
      if (beforeSplit < aggregators.size()) {
        outerVirtualColumns.add(qc);
        continue;
      }
    }
    if (virtualColumns == null) {
      virtualColumns=new ObjList<>();
    }
    VirtualColumn vc=virtualColumnBuilder.createVirtualColumn(model,qc.getAst(),recordSource.getMetadata());
    vc.setName(qc.getAlias());
    virtualColumns.add(vc);
    groupKeyColumns.add(qc.getAlias());
  }
  RecordSource rs=recordSource;
  if (virtualColumns != null) {
    rs=new VirtualColumnRecordSource(rs,virtualColumns);
  }
  ExprNode sampleBy=model.getSampleBy();
  int asz=aggregators.size();
  if (asz > 0) {
    ObjList<AggregatorFunction> af=new ObjList<>(asz);
    for (int i=0; i < asz; i++) {
      QueryColumn qc=aggregators.get(i);
      VirtualColumn vc=virtualColumnBuilder.createVirtualColumn(model,qc.getAst(),rs.getMetadata());
      if (vc instanceof AggregatorFunction) {
        vc.setName(qc.getAlias());
        af.add((AggregatorFunction)vc);
      }
 else {
        throw QueryError.$(qc.getAst().position,"String_Node_Str");
      }
    }
    if (sampleBy == null) {
      rs=new AggregatedRecordSource(rs,groupKeyColumns,af);
    }
 else {
      TimestampSampler sampler=SamplerFactory.from(sampleBy.token);
      if (sampler == null) {
        throw QueryError.$(sampleBy.position,"String_Node_Str");
      }
      rs=new ResampledRecordSource(rs,groupKeyColumns,af,sampler);
    }
  }
 else {
    if (sampleBy != null) {
      throw QueryError.$(sampleBy.position,"String_Node_Str");
    }
  }
  if (outerVirtualColumns.size() > 0) {
    ObjList<VirtualColumn> outer=new ObjList<>(outerVirtualColumns.size());
    for (int i=0, n=outerVirtualColumns.size(); i < n; i++) {
      QueryColumn qc=outerVirtualColumns.get(i);
      VirtualColumn vc=virtualColumnBuilder.createVirtualColumn(model,qc.getAst(),rs.getMetadata());
      vc.setName(qc.getAlias());
      outer.add(vc);
    }
    rs=new VirtualColumnRecordSource(rs,outer);
  }
  if (selectedColumns.size() > 0) {
    rs=new SelectedColumnsRecordSource(rs,selectedColumns,selectedColumnAliases);
  }
  return rs;
}

Fixed version (ground truth):
@SuppressFBWarnings("String_Node_Str") private RecordSource selectColumns0(final RecordSource recordSource,QueryModel model) throws ParserException {
  final ObjList<QueryColumn> columns=model.getColumns();
  final CharSequenceIntHashMap columnNameHistogram=model.getColumnNameHistogram();
  final RecordMetadata meta=recordSource.getMetadata();
  this.outerVirtualColumns.clear();
  this.aggregators.clear();
  this.selectedColumns.clear();
  this.selectedColumnAliases.clear();
  this.groupKeyColumns.clear();
  this.aggregateColumnSequence=0;
  ObjList<VirtualColumn> virtualColumns=null;
  for (int i=0, k=columns.size(); i < k; i++) {
    final QueryColumn qc=columns.getQuick(i);
    final ExprNode node=qc.getAst();
    if (node.type == ExprNode.NodeType.LITERAL) {
      if (meta.getColumnIndexQuiet(node.token) == -1) {
        throw QueryError.invalidColumn(node.position,node.token);
      }
      if (columnNameHistogram.get(node.token) > 0) {
        throw QueryError.$(node.position,"String_Node_Str");
      }
      selectedColumns.add(node.token);
      addAlias(node.position,qc.getAlias() == null ? node.token : qc.getAlias());
      groupKeyColumns.add(node.token);
      continue;
    }
    if (qc.getAlias() == null) {
      qc.of(createAlias(aggregateColumnSequence++),node);
    }
    selectedColumns.add(qc.getAlias());
    addAlias(node.position,qc.getAlias());
    if (node.type == ExprNode.NodeType.FUNCTION && FunctionFactories.isAggregate(node.token)) {
      aggregators.add(qc);
      continue;
    }
    if (node.type == ExprNode.NodeType.OPERATION || node.type == ExprNode.NodeType.FUNCTION) {
      int beforeSplit=aggregators.size();
      splitAggregates(node,aggregators);
      if (beforeSplit < aggregators.size()) {
        outerVirtualColumns.add(qc);
        continue;
      }
    }
    if (virtualColumns == null) {
      virtualColumns=new ObjList<>();
    }
    VirtualColumn vc=virtualColumnBuilder.createVirtualColumn(model,qc.getAst(),recordSource.getMetadata());
    vc.setName(qc.getAlias());
    virtualColumns.add(vc);
    groupKeyColumns.add(qc.getAlias());
  }
  RecordSource rs=recordSource;
  if (virtualColumns != null) {
    rs=new VirtualColumnRecordSource(rs,virtualColumns);
  }
  ExprNode sampleBy=model.getSampleBy();
  int asz=aggregators.size();
  if (asz > 0) {
    ObjList<AggregatorFunction> af=new ObjList<>(asz);
    for (int i=0; i < asz; i++) {
      QueryColumn qc=aggregators.get(i);
      VirtualColumn vc=virtualColumnBuilder.createVirtualColumn(model,qc.getAst(),rs.getMetadata());
      if (vc instanceof AggregatorFunction) {
        vc.setName(qc.getAlias());
        af.add((AggregatorFunction)vc);
      }
 else {
        throw QueryError.$(qc.getAst().position,"String_Node_Str");
      }
    }
    if (sampleBy == null) {
      rs=new AggregatedRecordSource(rs,groupKeyColumns,af);
    }
 else {
      TimestampSampler sampler=SamplerFactory.from(sampleBy.token);
      if (sampler == null) {
        throw QueryError.$(sampleBy.position,"String_Node_Str");
      }
      rs=new ResampledRecordSource(rs,getTimestampIndex(model,model.getTimestamp(),rs.getMetadata()),groupKeyColumns,af,sampler);
    }
  }
 else {
    if (sampleBy != null) {
      throw QueryError.$(sampleBy.position,"String_Node_Str");
    }
  }
  if (outerVirtualColumns.size() > 0) {
    ObjList<VirtualColumn> outer=new ObjList<>(outerVirtualColumns.size());
    for (int i=0, n=outerVirtualColumns.size(); i < n; i++) {
      QueryColumn qc=outerVirtualColumns.get(i);
      VirtualColumn vc=virtualColumnBuilder.createVirtualColumn(model,qc.getAst(),rs.getMetadata());
      vc.setName(qc.getAlias());
      outer.add(vc);
    }
    rs=new VirtualColumnRecordSource(rs,outer);
  }
  if (selectedColumns.size() > 0) {
    rs=new SelectedColumnsRecordSource(rs,selectedColumns,selectedColumnAliases);
  }
  return rs;
}