Program: 95936
Project: 95936
Buggy source:
/** 
 * @param sourceAggMeta
 * @return Key: aggregate column list
 */
Triple<List<ColumnOp>,SqlConvertible,Map<Integer,String>> createBaseQueryForReplacement(AggMeta sourceAggMeta,ExecutionInfoToken token){
  Map<Integer,String> multipleTierTableTierInfo=new HashMap<>();
  List<ColumnOp> aggColumnlist=new ArrayList<>();
  List<HyperTableCube> cubes=sourceAggMeta.getCubes();
  SelectQuery dependentQuery=(SelectQuery)token.getValue("String_Node_Str");
  List<SelectItem> newSelectList=dependentQuery.deepcopy().getSelectList();
  AggMeta aggMeta=(AggMeta)token.getValue("String_Node_Str");
  for (  SelectItem selectItem : newSelectList) {
    if (selectItem instanceof AliasedColumn) {
      AliasedColumn aliasedColumn=(AliasedColumn)selectItem;
      int index=newSelectList.indexOf(selectItem);
      UnnamedColumn col=aliasedColumn.getColumn();
      if (aggMeta.getAggAlias().contains(aliasedColumn.getAliasName())) {
        ColumnOp aggColumn=ColumnOp.multiply(ConstantColumn.valueOf(1.0),new BaseColumn(INNER_RAW_AGG_TABLE_ALIAS,aliasedColumn.getAliasName()));
        aggColumnlist.add(aggColumn);
        newSelectList.set(index,new AliasedColumn(aggColumn,aliasedColumn.getAliasName()));
      }
 else       if (aggMeta.getMaxminAggAlias().keySet().contains(aliasedColumn.getAliasName())) {
        newSelectList.set(index,new AliasedColumn(new BaseColumn(INNER_RAW_AGG_TABLE_ALIAS,aliasedColumn.getAliasName()),aliasedColumn.getAliasName()));
      }
 else {
        if (!Initiated && col instanceof BaseColumn) {
          String schemaName=((BaseColumn)col).getSchemaName();
          String tableName=((BaseColumn)col).getTableName();
          if (scrambleMeta.isScrambled(schemaName,tableName) && ((BaseColumn)col).getColumnName().equals(scrambleMeta.getTierColumn(schemaName,tableName))) {
            for (            Dimension d : cubes.get(0).getDimensions()) {
              if (d.getTableName().equals(tableName) && d.getSchemaName().equals(schemaName)) {
                multipleTierTableTierInfo.put(cubes.get(0).getDimensions().indexOf(d),aliasedColumn.getAliasName());
                break;
              }
            }
          }
        }
        newSelectList.set(index,new AliasedColumn(new BaseColumn(INNER_RAW_AGG_TABLE_ALIAS,aliasedColumn.getAliasName()),aliasedColumn.getAliasName()));
      }
    }
  }
  SelectQuery query=SelectQuery.create(newSelectList,new BaseTable((String)token.getValue("String_Node_Str"),(String)token.getValue("String_Node_Str"),INNER_RAW_AGG_TABLE_ALIAS));
  return Triple.of(aggColumnlist,(SqlConvertible)query,multipleTierTableTierInfo);
}

Fixed version (ground truth):
/** 
 * @param sourceAggMeta AggMeta instance passed from a downstream node (either an individualaggregate node or a combiner node). This object contains what are the tier columns for the scrambled tables they cover and what aggregates are being computed.
 * @return Key: aggregate column list
 */
private Triple<List<ColumnOp>,SqlConvertible,Map<Integer,String>> createBaseQueryForReplacement(AggMeta sourceAggMeta,ExecutionInfoToken token){
  Map<Integer,String> multipleTierTableTierInfo=new HashMap<>();
  List<ColumnOp> aggColumnlist=new ArrayList<>();
  ScrambleMetaSet scrambleMetaSet=getScrambleMeta();
  List<HyperTableCube> cubes=sourceAggMeta.getCubes();
  SelectQuery dependentQuery=(SelectQuery)token.getValue("String_Node_Str");
  List<SelectItem> newSelectList=dependentQuery.deepcopy().getSelectList();
  for (  SelectItem selectItem : newSelectList) {
    if (selectItem instanceof AliasedColumn) {
      AliasedColumn aliasedColumn=(AliasedColumn)selectItem;
      int index=newSelectList.indexOf(selectItem);
      UnnamedColumn col=aliasedColumn.getColumn();
      if (sourceAggMeta.getAggAlias().contains(aliasedColumn.getAliasName())) {
        ColumnOp aggColumn=ColumnOp.multiply(ConstantColumn.valueOf(1.0),new BaseColumn(INNER_RAW_AGG_TABLE_ALIAS,aliasedColumn.getAliasName()));
        aggColumnlist.add(aggColumn);
        newSelectList.set(index,new AliasedColumn(aggColumn,aliasedColumn.getAliasName()));
      }
 else       if (sourceAggMeta.getMaxminAggAlias().keySet().contains(aliasedColumn.getAliasName())) {
        newSelectList.set(index,new AliasedColumn(new BaseColumn(INNER_RAW_AGG_TABLE_ALIAS,aliasedColumn.getAliasName()),aliasedColumn.getAliasName()));
      }
 else {
        if (col instanceof BaseColumn) {
          String schemaName=((BaseColumn)col).getSchemaName();
          String tableName=((BaseColumn)col).getTableName();
          if (scrambleMetaSet.isScrambled(schemaName,tableName) && ((BaseColumn)col).getColumnName().equals(scrambleMetaSet.getTierColumn(schemaName,tableName))) {
            for (            Dimension d : cubes.get(0).getDimensions()) {
              if (d.getTableName().equals(tableName) && d.getSchemaName().equals(schemaName)) {
                multipleTierTableTierInfo.put(cubes.get(0).getDimensions().indexOf(d),aliasedColumn.getAliasName());
                break;
              }
            }
          }
        }
        newSelectList.set(index,new AliasedColumn(new BaseColumn(INNER_RAW_AGG_TABLE_ALIAS,aliasedColumn.getAliasName()),aliasedColumn.getAliasName()));
      }
    }
  }
  SelectQuery query=SelectQuery.create(newSelectList,new BaseTable((String)token.getValue("String_Node_Str"),(String)token.getValue("String_Node_Str"),INNER_RAW_AGG_TABLE_ALIAS));
  return Triple.of(aggColumnlist,(SqlConvertible)query,multipleTierTableTierInfo);
}