public static String evaluateBuiltIn(
      Atom atom,
      Map<String, String> varmap,
      Map<String, ISqlExpression> whereExpressions,
      Set<ISqlExpression> whereRoots,
      List<Atom> allAtoms) {
    String sch = atom.getSchema().getSchemaId();
    String fn = atom.getRelation().getName();

    List<String> args = new ArrayList<String>();
    List<ISqlExp> children = newArrayList();
    // args.add(atom.getValues().get(0).toString());

    // Make sure the parameters are defined

    for (int i = 0 /*getFirstParm(sch, fn)*/; i < atom.getValues().size(); i++) {
      String arg = atom.getValues().get(i).toString();
      if (atom.getValues().get(i) instanceof AtomConst) {
        args.add(arg);
        try {
          Integer.valueOf(arg);
          children.add(_sqlFactory.newConstant(arg, ISqlConstant.Type.NUMBER));
        } catch (NumberFormatException ne) {

          // Trim '' because the parent class already adds these to a string
          if (arg.charAt(0) == '\'' && arg.charAt(arg.length() - 1) == '\'') {
            arg = arg.substring(1, arg.length() - 1);
          }
          children.add(_sqlFactory.newConstant(arg, ISqlConstant.Type.STRING));
        }
      } else if (varmap.get(arg) == null && i >= getFirstParm(sch, fn)) return "";
      else if (i >= getFirstParm(sch, fn)) {
        args.add(getArgumentForVar(fn, arg, i, varmap, allAtoms));
        if (whereExpressions.get(arg) != null) children.add(whereExpressions.get(arg));
        else
          children.add(
              _sqlFactory.newConstant(
                  getArgumentForVar(fn, arg, i, varmap, allAtoms), ISqlConstant.Type.COLUMNNAME));
        // This is no longer the root of a condition -- it's a subexpression
        //				_whereRoots.remove(_whereExpressions.get(arg));
      }
    }

    ISqlExpression newExpr = BuiltinFunctions.getExpression(sch, fn, children);

    if (newExpr.isBoolean()) whereRoots.add(newExpr);
    else whereExpressions.put(atom.getValues().get(0).toString(), newExpr);

    return BuiltinFunctions.getResultString(sch, fn, args);
  }
 public static ISqlExpression getExpression(String sch, String fn, List<ISqlExp> args) {
   if (sch.equals("COMPARE")) {
     if (fn.equals("INTLESS")) {
       return _sqlFactory.newExpression(ISqlExpression.Code.LT, args.get(0), args.get(1));
     } else if (fn.equals("INTLESSEQUAL")) {
       return _sqlFactory.newExpression(ISqlExpression.Code.LTE, args.get(0), args.get(1));
     } else if (fn.equals("INTGREATER")) {
       return _sqlFactory.newExpression(ISqlExpression.Code.GT, args.get(0), args.get(1));
     } else if (fn.equals("INTGREATEREQUAL")) {
       return _sqlFactory.newExpression(ISqlExpression.Code.GTE, args.get(0), args.get(1));
     } else if (fn.equals("INTEQUAL")) {
       return _sqlFactory.newExpression(ISqlExpression.Code.EQ, args.get(0), args.get(1));
     } else if (fn.equals("INTNOTEQUAL")) {
       return _sqlFactory.newExpression(ISqlExpression.Code.NEQ, args.get(0), args.get(1));
     } else if (fn.equals("STRLIKE")) {
       return _sqlFactory.newExpression(ISqlExpression.Code.LIKE, args.get(0), args.get(1));
     }
   } else if (sch.equals("ARITH")) {
     if (fn.equals("INTADD")) {
       return _sqlFactory.newExpression(ISqlExpression.Code.PLUSSIGN, args.get(0), args.get(1));
     } else if (fn.equals("INTSUB")) {
       return _sqlFactory.newExpression(ISqlExpression.Code.MINUSSIGN, args.get(0), args.get(1));
     } else if (fn.equals("INTMUL")) {
       return _sqlFactory.newExpression(ISqlExpression.Code.MULTSIGN, args.get(0), args.get(1));
     } else if (fn.equals("INTDIV")) {
       return _sqlFactory.newExpression(ISqlExpression.Code.DIVSIGN, args.get(0), args.get(1));
     }
   } else if (sch.equals("STRING")) {
     if (fn.equals("STRCAT")) {
       return _sqlFactory.newExpression(ISqlExpression.Code.PIPESSIGN, args.get(0), args.get(1));
       /*
       } else if (fn.equals("SUBSTR")) {
       	return _sqlFactory.newSqlExpression(ISqlExpression.Code.)
       } else if (fn.equals("STRLEN")) {
       	return "LENGTH(" + args.get(1) + ")";
       	*/
     }
   } else if (sch.equals("EQUALITYUDFSL") || sch.equals("EQUALITYUDFSR")) {
     ISqlExpression s = _sqlFactory.newExpression(ISqlExpression.Code._NOT_SUPPORTED, args.get(0));
     s.setOperator(fn);
     for (int i = 1; i < args.size(); i++) s.addOperand(args.get(i));
     return s;
   }
   return null;
 }