Program: 31254
Project: 31254
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;
  this.analyticColumns.clear();
  this.orderedAnalytic=false;
  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();
    final boolean analytic=qc instanceof AnalyticColumn;
    if (!analytic && 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.ambiguousColumn(node.position);
      }
      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 (!analytic && 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 (analytic) {
      if (qc.getAst().type != ExprNode.NodeType.FUNCTION) {
        throw QueryError.$(qc.getAst().position,"String_Node_Str");
      }
      if (aggregators.size() > 0) {
        throw QueryError.$(qc.getAst().position,"String_Node_Str");
      }
      AnalyticColumn ac=(AnalyticColumn)qc;
      orderedAnalytic=ac.getOrderBy().size() > 0;
      analyticColumns.add(ac);
    }
 else {
      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);
  }
  if (aggregators.size() > 0) {
    rs=compileAggregates(rs,model);
  }
 else {
    ExprNode sampleBy=model.getSampleBy();
    if (sampleBy != null) {
      throw QueryError.$(sampleBy.position,"String_Node_Str");
    }
  }
  if (outerVirtualColumns.size() > 0) {
    rs=compileOuterVirtualColumns(rs,model);
  }
  if (analyticColumns.size() > 0) {
    rs=compileAnalytic(rs,model);
  }
  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;
  this.analyticColumns.clear();
  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();
    final boolean analytic=qc instanceof AnalyticColumn;
    if (!analytic && 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.ambiguousColumn(node.position);
      }
      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 (!analytic && 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 (analytic) {
      if (qc.getAst().type != ExprNode.NodeType.FUNCTION) {
        throw QueryError.$(qc.getAst().position,"String_Node_Str");
      }
      if (aggregators.size() > 0) {
        throw QueryError.$(qc.getAst().position,"String_Node_Str");
      }
      AnalyticColumn ac=(AnalyticColumn)qc;
      analyticColumns.add(ac);
    }
 else {
      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);
  }
  if (aggregators.size() > 0) {
    rs=compileAggregates(rs,model);
  }
 else {
    ExprNode sampleBy=model.getSampleBy();
    if (sampleBy != null) {
      throw QueryError.$(sampleBy.position,"String_Node_Str");
    }
  }
  if (outerVirtualColumns.size() > 0) {
    rs=compileOuterVirtualColumns(rs,model);
  }
  if (analyticColumns.size() > 0) {
    rs=compileAnalytic(rs,model);
  }
  if (selectedColumns.size() > 0) {
    rs=new SelectedColumnsRecordSource(rs,selectedColumns,selectedColumnAliases);
  }
  return rs;
}