Program: 74009
Project: 74009
Buggy source:
/** 
 * @return
 */
private QueryDefinition newGenIVReportQuery(){
  QueryDefinition qd=newReportQuery();
  IBaseExpression[] rowBeArray=getRowExpr();
  IBaseExpression[] 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"));
  for (int i=0; i < totalBeArray.length; i++)   qd.addResultSetExpression(this.totalExprName[i],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);
  }
  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=new SubqueryDefinition(subQueryName1,qd);
      subRowExprName1=new String[3];
      subRowExprName1[0]="String_Node_Str";
      subRowExprName1[1]="String_Node_Str";
      subRowExprName1[2]="String_Node_Str";
      ScriptExpression[] exprs=new ScriptExpression[3];
      exprs[0]=new ScriptExpression("String_Node_Str");
      exprs[1]=new ScriptExpression("String_Node_Str");
      exprs[2]=new ScriptExpression("String_Node_Str");
      for (int i=0; i < subRowExprName1.length; i++)       subqueryDefn.addResultSetExpression(subRowExprName1[i],exprs[i]);
      if (this.USE_DATE_IN_SUBQUERY)       subqueryDefn.addResultSetExpression("String_Node_Str",new ScriptExpression("String_Node_Str"));
      subqueryDefn.setApplyOnGroupFlag(true);
      gd.addSubquery(subqueryDefn);
    }
  }
  return qd;
}

Fixed version (ground truth):
/** 
 * @return
 */
private QueryDefinition newGenIVReportQuery(){
  QueryDefinition qd=newReportQuery();
  IBaseExpression[] rowBeArray=getRowExpr();
  IBaseExpression[] 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.addResultSetExpression(this.totalExprName[i],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 (add_subquery_on_query) {
    qd.addSubquery(getSubQueryDefn(qd));
  }
  return qd;
}