Program: 95948
Project: 95948
Buggy source:
@Override public SqlConvertible createQuery(List<ExecutionInfoToken> tokens) throws VerdictDBException {
  savedToken=tokens.get(0);
  List<HyperTableCube> cubes=((AggMeta)savedToken.getValue("String_Node_Str")).getCubes();
  HashMap<List<Integer>,Double> scaleFactor=calculateScaleFactor(cubes);
  Pair<List<ColumnOp>,SqlConvertible> aggColumnsAndQuery=createBaseQueryForReplacement(cubes);
  if (scaleFactor.size() == 1) {
    Double s=(Double)(scaleFactor.values().toArray())[0];
    for (    ColumnOp col : aggColumnsAndQuery.getLeft()) {
      col.setOperand(0,ConstantColumn.valueOf(String.format("String_Node_Str",s)));
    }
  }
 else {
    for (    ColumnOp col : aggColumnsAndQuery.getLeft()) {
      String alias=((BaseColumn)col.getOperand(1)).getColumnName();
      col.setOpType("String_Node_Str");
      List<UnnamedColumn> operands=new ArrayList<>();
      for (      Map.Entry<List<Integer>,Double> entry : scaleFactor.entrySet()) {
        UnnamedColumn condition=generateCaseCondition(entry.getKey());
        operands.add(condition);
        ColumnOp multiply=new ColumnOp("String_Node_Str",Arrays.asList(ConstantColumn.valueOf(String.format("String_Node_Str",entry.getValue())),col.getOperand(1)));
        operands.add(multiply);
      }
      operands.add(ConstantColumn.valueOf(0));
      col.setOperand(operands);
    }
  }
  SelectQuery query;
  if (multipleTierTableTierInfo.size() > 0) {
    query=sumUpTierGroup((SelectQuery)aggColumnsAndQuery.getRight(),((AggMeta)savedToken.getValue("String_Node_Str")));
  }
 else   query=(SelectQuery)aggColumnsAndQuery.getRight();
  Pair<String,String> tempTableFullName=getNamer().generateTempTableName();
  newTableSchemaName=tempTableFullName.getLeft();
  newTableName=tempTableFullName.getRight();
  SelectQuery createTableQuery=replaceWithOriginalSelectList(query,((AggMeta)savedToken.getValue("String_Node_Str")));
  if (selectQuery != null) {
    if (!selectQuery.getGroupby().isEmpty()) {
      createTableQuery.addGroupby(selectQuery.getGroupby());
    }
    if (!selectQuery.getOrderby().isEmpty()) {
      createTableQuery.addOrderby(selectQuery.getOrderby());
    }
    if (selectQuery.getHaving().isPresent()) {
      createTableQuery.addHavingByAnd(selectQuery.getHaving().get());
    }
    if (selectQuery.getLimit().isPresent()) {
      createTableQuery.addLimit(selectQuery.getLimit().get());
    }
  }
  CreateTableAsSelectQuery createQuery=new CreateTableAsSelectQuery(newTableSchemaName,newTableName,createTableQuery);
  return createQuery;
}

Fixed version (ground truth):
@Override public SqlConvertible createQuery(List<ExecutionInfoToken> tokens) throws VerdictDBException {
  savedToken=tokens.get(0);
  List<HyperTableCube> cubes=((AggMeta)savedToken.getValue("String_Node_Str")).getCubes();
  HashMap<List<Integer>,Double> scaleFactor=calculateScaleFactor(cubes);
  Pair<List<ColumnOp>,SqlConvertible> aggColumnsAndQuery=createBaseQueryForReplacement(cubes);
  if (scaleFactor.size() == 1) {
    Double s=(Double)(scaleFactor.values().toArray())[0];
    for (    ColumnOp col : aggColumnsAndQuery.getLeft()) {
      col.setOperand(0,ConstantColumn.valueOf(String.format("String_Node_Str",s)));
    }
  }
 else {
    for (    ColumnOp col : aggColumnsAndQuery.getLeft()) {
      String alias=((BaseColumn)col.getOperand(1)).getColumnName();
      col.setOpType("String_Node_Str");
      List<UnnamedColumn> operands=new ArrayList<>();
      for (      Map.Entry<List<Integer>,Double> entry : scaleFactor.entrySet()) {
        UnnamedColumn condition=generateCaseCondition(entry.getKey());
        operands.add(condition);
        ColumnOp multiply=new ColumnOp("String_Node_Str",Arrays.asList(ConstantColumn.valueOf(String.format("String_Node_Str",entry.getValue())),col.getOperand(1)));
        operands.add(multiply);
      }
      operands.add(ConstantColumn.valueOf(0));
      col.setOperand(operands);
    }
  }
  SelectQuery query;
  if (multipleTierTableTierInfo.size() > 0) {
    query=sumUpTierGroup((SelectQuery)aggColumnsAndQuery.getRight(),((AggMeta)savedToken.getValue("String_Node_Str")));
  }
 else   query=(SelectQuery)aggColumnsAndQuery.getRight();
  Pair<String,String> tempTableFullName=getNamer().generateTempTableName();
  newTableSchemaName=tempTableFullName.getLeft();
  newTableName=tempTableFullName.getRight();
  SelectQuery createTableQuery=replaceWithOriginalSelectList(query,((AggMeta)savedToken.getValue("String_Node_Str")));
  if (selectQuery != null) {
    if (!selectQuery.getGroupby().isEmpty() && selectQuery.getHaving().isPresent()) {
      createTableQuery.addGroupby(selectQuery.getGroupby());
    }
    if (!selectQuery.getOrderby().isEmpty()) {
      createTableQuery.addOrderby(selectQuery.getOrderby());
    }
    if (selectQuery.getHaving().isPresent()) {
      createTableQuery.addHavingByAnd(selectQuery.getHaving().get());
    }
    if (selectQuery.getLimit().isPresent()) {
      createTableQuery.addLimit(selectQuery.getLimit().get());
    }
  }
  CreateTableAsSelectQuery createQuery=new CreateTableAsSelectQuery(newTableSchemaName,newTableName,createTableQuery);
  return createQuery;
}