Program: 9831
Project: 9831
Buggy source:
/** 
 * Pushes all constants of a given mapping's varDefinition into the SQL. Used for creating union's of mappings: By pushing variables into the SQL we do not have to deal with disjoint unions (i.e. unions with discriminator columns) in order to know which union member yields the constant. 
 * @param mapping The mapping to process. 
 * @return A new mapping with all constants pushed.
 */
public static Mapping pushConstants(Mapping mapping){
  VarDefinition varDef=mapping.getVarDefinition();
  Set<String> columnNameBlacklist=new HashSet<String>(mapping.getSqlOp().getSchema().getColumnNames());
  Generator aliasGen=GeneratorBlacklist.create("String_Node_Str",columnNameBlacklist);
  Projection projection=new Projection();
  VarDefinition newVarDef=new VarDefinition();
  for (  Entry<Var,Collection<RestrictedExpr>> entry : varDef.getMap().asMap().entrySet()) {
    Var var=entry.getKey();
    Collection<RestrictedExpr> restExprs=entry.getValue();
    for (    RestrictedExpr restExpr : restExprs) {
      Expr newExpr;
      Expr expr=restExpr.getExpr();
      E_RdfTerm rdfTerm;
      if (expr.isConstant()) {
        rdfTerm=SqlTranslationUtils.expandConstant(expr);
      }
 else {
        rdfTerm=SqlTranslationUtils.expandRdfTerm(expr);
      }
      boolean isConstantArgsOnly=ExprUtils.isConstantArgsOnly(rdfTerm);
      if (isConstantArgsOnly) {
        NodeValue constant=expr.eval(null,null);
        String alias=aliasGen.next();
        String str="String_Node_Str" + NodeValueUtils.getValue(constant);
        S_Constant sqlExpr=new S_Constant(new SqlValue(TypeToken.String,str));
        projection.put(alias,sqlExpr);
        ExprVar exprVar=new ExprVar(alias);
        ExprList exprs=new ExprList();
        List<Expr> args=rdfTerm.getArgs();
        for (int j=0; j < args.size(); ++j) {
          Expr e;
          if (j == 1) {
            e=exprVar;
          }
 else {
            e=args.get(j);
          }
          exprs.add(e);
        }
        newExpr=ExprCopy.getInstance().copy(expr,exprs);
      }
 else {
        newExpr=expr;
      }
      RestrictedExpr newRestExpr=new RestrictedExpr(newExpr,restExpr.getRestrictions());
      newVarDef.getMap().put(var,newRestExpr);
    }
  }
  Mapping result;
  if (projection.isEmpty()) {
    result=mapping;
  }
 else {
    SqlOp sqlOp=mapping.getSqlOp();
    SqlOp newSqlOp=SqlOpExtend.create(sqlOp,projection);
    result=new Mapping(newVarDef,newSqlOp);
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Pushes all constants of a given mapping's varDefinition into the SQL. Used for creating union's of mappings: By pushing variables into the SQL we do not have to deal with disjoint unions (i.e. unions with discriminator columns) in order to know which union member yields the constant. 
 * @param mapping The mapping to process. 
 * @return A new mapping with all constants pushed.
 */
public static Mapping pushConstants(Mapping mapping){
  VarDefinition varDef=mapping.getVarDefinition();
  Set<String> columnNameBlacklist=new HashSet<String>(mapping.getSqlOp().getSchema().getColumnNames());
  Generator aliasGen=GeneratorBlacklist.create("String_Node_Str",columnNameBlacklist);
  Projection projection=new Projection();
  VarDefinition newVarDef=new VarDefinition();
  for (  Entry<Var,Collection<RestrictedExpr>> entry : varDef.getMap().asMap().entrySet()) {
    Var var=entry.getKey();
    Collection<RestrictedExpr> restExprs=entry.getValue();
    for (    RestrictedExpr restExpr : restExprs) {
      Expr newExpr;
      Expr expr=restExpr.getExpr();
      E_RdfTerm rdfTerm;
      if (expr.isConstant()) {
        rdfTerm=SqlTranslationUtils.expandConstant(expr);
      }
 else {
        rdfTerm=SqlTranslationUtils.expandRdfTerm(expr);
      }
      boolean isConstantArgsOnly=ExprUtils.isConstantArgsOnly(rdfTerm);
      if (isConstantArgsOnly) {
        NodeValue constant=expr.eval(null,null);
        String alias=aliasGen.next();
        String str="String_Node_Str" + NodeValueUtils.getValue(constant);
        S_Constant sqlExpr=new S_Constant(new SqlValue(TypeToken.String,str));
        projection.put(alias,sqlExpr);
        ExprVar exprVar=new ExprVar(alias);
        ExprList exprs=new ExprList();
        List<Expr> args=rdfTerm.getArgs();
        for (int j=0; j < args.size(); ++j) {
          Expr e;
          if (j == 1) {
            e=exprVar;
          }
 else {
            e=args.get(j);
          }
          exprs.add(e);
        }
        newExpr=ExprCopy.getInstance().copy(rdfTerm,exprs);
      }
 else {
        newExpr=expr;
      }
      RestrictedExpr newRestExpr=new RestrictedExpr(newExpr,restExpr.getRestrictions());
      newVarDef.getMap().put(var,newRestExpr);
    }
  }
  Mapping result;
  if (projection.isEmpty()) {
    result=mapping;
  }
 else {
    SqlOp sqlOp=mapping.getSqlOp();
    SqlOp newSqlOp=SqlOpExtend.create(sqlOp,projection);
    result=new Mapping(newVarDef,newSqlOp);
  }
  return result;
}