Program: 65480
Project: 65480
Buggy source:
/** 
 * @return
 * @throws DataException 
 */
private QueryDefinition newGenIVReportQuery() throws DataException {
  QueryDefinition qd=newReportQuery();
  IBaseExpression[] rowBeArray=getRowExpr();
  IBinding[] totalBeArray=getAggrExpr();
  for (int i=0; i < rowBeArray.length; i++)   qd.addResultSetExpression(this.rowExprName[i],rowBeArray[i]);
  if (this.GEN_use_invalid_column)   qd.addResultSetExpression("String_Node_Str",new ScriptExpression("String_Node_Str"));
  if (!this.notIncludeAggr) {
    for (int i=0; i < totalBeArray.length; i++)     qd.addBinding(totalBeArray[i]);
  }
  if (this.GEN_add_filter == true) {
    ConditionalExpression filterExpr=new ConditionalExpression("String_Node_Str",IConditionalExpression.OP_GT,"String_Node_Str");
    FilterDefinition filterDefn=new FilterDefinition(filterExpr);
    qd.addFilter(filterDefn);
    this.GEN_filterDefn.add(filterDefn);
  }
  if (this.TEST_ISEMPTY) {
    ConditionalExpression filterExpr=new ConditionalExpression("String_Node_Str",IConditionalExpression.OP_GT,"String_Node_Str");
    FilterDefinition filterDefn=new FilterDefinition(filterExpr);
    qd.addFilter(filterDefn);
    this.GEN_filterDefn.add(filterDefn);
  }
  if (this.GEN_add_sort) {
    SortDefinition sortDefn=new SortDefinition();
    sortDefn.setColumn("String_Node_Str");
    qd.addSort(sortDefn);
  }
  if (this.GEN_add_group == true) {
    GroupDefinition gd=new GroupDefinition();
    gd.setKeyColumn("String_Node_Str");
    qd.addGroup(gd);
    if (this.GEN_add_subquery == true) {
      SubqueryDefinition subqueryDefn=getSubQueryDefn(qd);
      gd.addSubquery(subqueryDefn);
    }
  }
  if (this.GEN_add_group1 == true) {
    GroupDefinition gd=new GroupDefinition();
    gd.setKeyColumn("String_Node_Str");
    qd.addGroup(gd);
    gd=new GroupDefinition();
    gd.setKeyColumn("String_Node_Str");
    qd.addGroup(gd);
  }
  if (add_subquery_on_query) {
    qd.addSubquery(getSubQueryDefn(qd));
  }
  return qd;
}

Fixed version (ground truth):
/** 
 * @return
 * @throws DataException 
 */
private QueryDefinition newGenIVReportQuery() throws DataException {
  QueryDefinition qd=newReportQuery();
  IBaseExpression[] rowBeArray=getRowExpr();
  IBinding[] totalBeArray=getAggrExpr();
  for (int i=0; i < rowBeArray.length; i++)   qd.addResultSetExpression(this.rowExprName[i],rowBeArray[i]);
  if (this.GEN_use_invalid_column)   qd.addResultSetExpression("String_Node_Str",new ScriptExpression("String_Node_Str"));
  if (!this.notIncludeAggr) {
    for (int i=0; i < totalBeArray.length; i++)     qd.addBinding(totalBeArray[i]);
  }
  if (this.GEN_add_filter == true) {
    ConditionalExpression filterExpr=new ConditionalExpression("String_Node_Str",IConditionalExpression.OP_GT,"String_Node_Str");
    FilterDefinition filterDefn=new FilterDefinition(filterExpr);
    qd.addFilter(filterDefn);
    this.GEN_filterDefn.add(filterDefn);
  }
  if (this.GEN_add_topN_filter == true) {
    ConditionalExpression filterExpr=new ConditionalExpression("String_Node_Str",IConditionalExpression.OP_TOP_N,"String_Node_Str");
    FilterDefinition filterDefn=new FilterDefinition(filterExpr);
    qd.addFilter(filterDefn);
    filterDefn.setFilterTarget(FilterTarget.DATASET);
    this.GEN_filterDefn.add(filterDefn);
  }
  if (this.TEST_ISEMPTY) {
    ConditionalExpression filterExpr=new ConditionalExpression("String_Node_Str",IConditionalExpression.OP_GT,"String_Node_Str");
    FilterDefinition filterDefn=new FilterDefinition(filterExpr);
    qd.addFilter(filterDefn);
    this.GEN_filterDefn.add(filterDefn);
  }
  if (this.GEN_add_sort) {
    SortDefinition sortDefn=new SortDefinition();
    sortDefn.setColumn("String_Node_Str");
    qd.addSort(sortDefn);
  }
  if (this.GEN_add_group == true) {
    GroupDefinition gd=new GroupDefinition();
    gd.setKeyColumn("String_Node_Str");
    qd.addGroup(gd);
    if (this.GEN_add_subquery == true) {
      SubqueryDefinition subqueryDefn=getSubQueryDefn(qd);
      gd.addSubquery(subqueryDefn);
    }
  }
  if (this.GEN_add_group1 == true) {
    GroupDefinition gd=new GroupDefinition();
    gd.setKeyColumn("String_Node_Str");
    qd.addGroup(gd);
    gd=new GroupDefinition();
    gd.setKeyColumn("String_Node_Str");
    qd.addGroup(gd);
  }
  if (add_subquery_on_query) {
    qd.addSubquery(getSubQueryDefn(qd));
  }
  return qd;
}