private static Double functionCost(RexCall call) {
      switch (call.getKind()) {
        case EQUALS:
        case NOT_EQUALS:
        case LESS_THAN:
        case GREATER_THAN:
        case LESS_THAN_OR_EQUAL:
        case GREATER_THAN_OR_EQUAL:
        case IS_NOT_NULL:
        case IS_NULL:
        case IS_TRUE:
        case IS_NOT_TRUE:
        case IS_FALSE:
        case IS_NOT_FALSE:
          return 1d;

        case BETWEEN:
          return 3d;

        case AND:
        case OR:
          return 1d * call.getOperands().size();

        case CAST:
          // This heuristic represents that CAST operation is 8 times more expensive
          // than a comparison operation such as EQUALS, NOT_EQUALS, etc.
          return 8d;

        default:
          if (HiveIn.INSTANCE.equals(call.op)) {
            return 2d * (call.getOperands().size() - 1);
          }
          // By default, we give this heuristic value to unrecognized functions.
          // The idea is that those functions will be more expensive to evaluate
          // than the simple functions considered above.
          // TODO: Add more functions/improve the heuristic after running additional experiments.
          return 32d;
      }
    }
The cost of a call expression e is computed as:
cost(e) = functionCost + sum_1..n(byteSize(o_i) + cost(o_i))
with the call having operands i in 1..n.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveFilterSortPredicates.java