fe/src/main/java/com/cloudera/impala/catalog/ScalarFunction.java
/**
   * Creates a builtin scalar operator function. This is a helper that wraps a few steps
   * into one call.
   * TODO: this needs to be kept in sync with what generates the be operator
   * implementations. (gen_functions.py). Is there a better way to coordinate this.
   */
Creates a builtin scalar operator function. This is a helper that wraps a few steps
into one call.
TODO: this needs to be kept in sync with what generates the be operator
implementations.
Creates a builtin scalar operator function . This is a helper that wraps a few steps into one call . TODO : this needs to be kept in sync with what generates the be operator implementations .
public static ScalarFunction createBuiltinOperator(String name,
      ArrayList<ColumnType> argTypes, ColumnType retType) {
    String beFn = Character.toUpperCase(name.charAt(0)) + name.substring(1);
    boolean usesDecimal = false;
    for (int i = 0; i < argTypes.size(); ++i) {
      switch (argTypes.get(i).getPrimitiveType()) {
        case BOOLEAN:
          beFn += "_bool";
          break;
        case TINYINT:
          beFn += "_char";
          break;
        case SMALLINT:
          beFn += "_short";
          break;
        case INT:
          beFn += "_int";
          break;
        case BIGINT:
          beFn += "_long";
          break;
        case FLOAT:
          beFn += "_float";
          break;
        case DOUBLE:
          beFn += "_double";
          break;
        case STRING:
          beFn += "_StringValue";
          break;
        case TIMESTAMP:
          beFn += "_TimestampValue";
          break;
        case DECIMAL:
          beFn += "_decimal";
          usesDecimal = true;
          break;
        default:
          Preconditions.checkState(false);
      }
    }
    String beClass = usesDecimal ? "DecimalOperators" : "ComputeFunctions";
    return createBuiltinOperator(name, beClass, beFn, argTypes, retType);
  }
public static ScalarFunction createBuiltinOperator ( String name , ArrayList < ColumnType > argTypes , ColumnType retType ) { String beFn = Character . toUpperCase ( name . charAt ( 0 ) ) + name . substring ( 1 ) ; boolean usesDecimal = false ; for ( int i = 0 ; i < argTypes . size ( ) ; ++ i ) { switch ( argTypes . get ( i ) . getPrimitiveType ( ) ) { case BOOLEAN : beFn += "_bool" ; break ; case TINYINT : beFn += "_char" ; break ; case SMALLINT : beFn += "_short" ; break ; case INT : beFn += "_int" ; break ; case BIGINT : beFn += "_long" ; break ; case FLOAT : beFn += "_float" ; break ; case DOUBLE : beFn += "_double" ; break ; case STRING : beFn += "_StringValue" ; break ; case TIMESTAMP : beFn += "_TimestampValue" ; break ; case DECIMAL : beFn += "_decimal" ; usesDecimal = true ; break ; default : Preconditions . checkState ( false ) ; } } String beClass = usesDecimal ? "DecimalOperators" : "ComputeFunctions" ; return createBuiltinOperator ( name , beClass , beFn , argTypes , retType ) ; }
Creates a builtin scalar operator function.
Creates a builtin scalar operator function .
// Operators have a well defined symbol based on the function name and type. // Convert Add(TINYINT, TINYINT) --> Add_char_char