Program: 95935
Project: 95935
Buggy source:
@Override public SqlConvertible createQuery(List<ExecutionInfoToken> tokens) throws VerdictDBException {
  ExecutionInfoToken token=tokens.get(0);
  AggMeta sourceAggMeta=(AggMeta)token.getValue("String_Node_Str");
  Triple<List<ColumnOp>,SqlConvertible,Map<Integer,String>> aggColumnsAndQuery=createBaseQueryForReplacement(sourceAggMeta,token);
  SelectQuery baseQuery=(SelectQuery)aggColumnsAndQuery.getMiddle();
  List<ColumnOp> aggColumns=aggColumnsAndQuery.getLeft();
  Map<Integer,String> multipleTierTableTierInfo=aggColumnsAndQuery.getRight();
  HashMap<List<Integer>,Double> scaleFactor=calculateScaleFactor(sourceAggMeta,multipleTierTableTierInfo);
  if (scaleFactor.size() == 1) {
    Double s=(Double)(scaleFactor.values().toArray())[0];
    for (    ColumnOp col : aggColumns) {
      col.setOperand(0,ConstantColumn.valueOf(String.format("String_Node_Str",s)));
    }
  }
 else {
    for (    ColumnOp col : aggColumns) {
      col.setOpType("String_Node_Str");
      List<UnnamedColumn> operands=new ArrayList<>();
      for (      Map.Entry<List<Integer>,Double> entry : scaleFactor.entrySet()) {
        UnnamedColumn condition=generateCaseCondition(entry.getKey(),multipleTierTableTierInfo);
        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=sumUpTierGroup(baseQuery,((AggMeta)token.getValue("String_Node_Str")),multipleTierTableTierInfo);
  Pair<String,String> tempTableFullName=getNamer().generateTempTableName();
  newTableSchemaName=tempTableFullName.getLeft();
  newTableName=tempTableFullName.getRight();
  SelectQuery createTableQuery=replaceWithOriginalSelectList(query,((AggMeta)token.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;
}

Fixed version (ground truth):
@Override public SqlConvertible createQuery(List<ExecutionInfoToken> tokens) throws VerdictDBException {
  ExecutionInfoToken token=tokens.get(0);
  AggMeta sourceAggMeta=(AggMeta)token.getValue("String_Node_Str");
  Triple<List<ColumnOp>,SqlConvertible,Map<Integer,String>> aggColumnsAndQuery=createBaseQueryForReplacement(sourceAggMeta,token);
  List<ColumnOp> aggColumns=aggColumnsAndQuery.getLeft();
  SelectQuery baseQuery=(SelectQuery)aggColumnsAndQuery.getMiddle();
  Map<Integer,String> multipleTierTableTierInfo=aggColumnsAndQuery.getRight();
  HashMap<List<Integer>,Double> scaleFactor=calculateScaleFactor(sourceAggMeta,multipleTierTableTierInfo);
  if (scaleFactor.size() == 1) {
    Double s=(Double)(scaleFactor.values().toArray())[0];
    for (    ColumnOp col : aggColumns) {
      col.setOperand(0,ConstantColumn.valueOf(String.format("String_Node_Str",s)));
    }
  }
 else {
    for (    ColumnOp col : aggColumns) {
      col.setOpType("String_Node_Str");
      List<UnnamedColumn> operands=new ArrayList<>();
      for (      Map.Entry<List<Integer>,Double> entry : scaleFactor.entrySet()) {
        List<Integer> tierPermutation=entry.getKey();
        UnnamedColumn condition=generateCaseCondition(tierPermutation,multipleTierTableTierInfo);
        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=sumUpTierGroup(baseQuery,((AggMeta)token.getValue("String_Node_Str")),multipleTierTableTierInfo);
  Pair<String,String> tempTableFullName=getNamer().generateTempTableName();
  newTableSchemaName=tempTableFullName.getLeft();
  newTableName=tempTableFullName.getRight();
  SelectQuery createTableQuery=replaceWithOriginalSelectList(query,((AggMeta)token.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;
}