kudu-protolib/src/main/java/com/streamsets/pipeline/stage/lib/kudu/KuduUtils.java
public static Field createField(RowResult result, String fieldName, Type type) throws StageException {
    switch (type) {
      case INT8:
        return Field.create(Field.Type.BYTE, result.getByte(fieldName));
      case INT16:
        return Field.create(Field.Type.SHORT, result.getShort(fieldName));
      case INT32:
        return Field.create(Field.Type.INTEGER, result.getInt(fieldName));
      case INT64:
        return Field.create(Field.Type.LONG, result.getLong(fieldName));
      case BINARY:
        try {
          return Field.create(Field.Type.BYTE_ARRAY, result.getBinary(fieldName));
        } catch (IllegalArgumentException ex) {
          throw new OnRecordErrorException(Errors.KUDU_35, fieldName);
        }
      case STRING:
        return Field.create(Field.Type.STRING, result.getString(fieldName));
      case BOOL:
        return Field.create(Field.Type.BOOLEAN, result.getBoolean(fieldName));
      case FLOAT:
        return Field.create(Field.Type.FLOAT, result.getFloat(fieldName));
      case DOUBLE:
        return Field.create(Field.Type.DOUBLE, result.getDouble(fieldName));
      case UNIXTIME_MICROS:
        //UNIXTIME_MICROS is in microsecond
        return Field.create(Field.Type.DATETIME, new Date(result.getLong(fieldName)/1000L));
      default:
        if ("DECIMAL".equals(type.name())) {
          return Field.create(Field.Type.DECIMAL, result.getDecimal(fieldName));
        }
        throw new StageException(Errors.KUDU_10, fieldName, type.getName());
    }
  }
public static Field createField(RowResult result, String fieldName, Type type) throws StageException {
    switch (type) {
      case INT8:
        return Field.create(Field.Type.BYTE, result.getByte(fieldName));
      case INT16:
        return Field.create(Field.Type.SHORT, result.getShort(fieldName));
      case INT32:
        return Field.create(Field.Type.INTEGER, result.getInt(fieldName));
      case INT64:
        return Field.create(Field.Type.LONG, result.getLong(fieldName));
      case BINARY:
        try {
          return Field.create(Field.Type.BYTE_ARRAY, result.getBinary(fieldName));
        } catch (IllegalArgumentException ex) {
          throw new OnRecordErrorException(Errors.KUDU_35, fieldName);
        }
      case STRING:
        return Field.create(Field.Type.STRING, result.getString(fieldName));
      case BOOL:
        return Field.create(Field.Type.BOOLEAN, result.getBoolean(fieldName));
      case FLOAT:
        return Field.create(Field.Type.FLOAT, result.getFloat(fieldName));
      case DOUBLE:
        return Field.create(Field.Type.DOUBLE, result.getDouble(fieldName));
      case UNIXTIME_MICROS:
        //UNIXTIME_MICROS is in microsecond
        return Field.create(Field.Type.DATETIME, new Date(result.getLong(fieldName)/1000L));
      default:
        if ("DECIMAL".equals(type.name())) {
          return Field.create(Field.Type.DECIMAL, result.getDecimal(fieldName));
        }
        throw new StageException(Errors.KUDU_10, fieldName, type.getName());
    }
  }
public static Field createField ( RowResult result , String fieldName , Type type ) throws StageException { switch ( type ) { case INT8 : return Field . create ( Field . Type . BYTE , result . getByte ( fieldName ) ) ; case INT16 : return Field . create ( Field . Type . SHORT , result . getShort ( fieldName ) ) ; case INT32 : return Field . create ( Field . Type . INTEGER , result . getInt ( fieldName ) ) ; case INT64 : return Field . create ( Field . Type . LONG , result . getLong ( fieldName ) ) ; case BINARY : try { return Field . create ( Field . Type . BYTE_ARRAY , result . getBinary ( fieldName ) ) ; } catch ( IllegalArgumentException ex ) { throw new OnRecordErrorException ( Errors . KUDU_35 , fieldName ) ; } case STRING : return Field . create ( Field . Type . STRING , result . getString ( fieldName ) ) ; case BOOL : return Field . create ( Field . Type . BOOLEAN , result . getBoolean ( fieldName ) ) ; case FLOAT : return Field . create ( Field . Type . FLOAT , result . getFloat ( fieldName ) ) ; case DOUBLE : return Field . create ( Field . Type . DOUBLE , result . getDouble ( fieldName ) ) ; case UNIXTIME_MICROS : //UNIXTIME_MICROS is in microsecond return Field . create ( Field . Type . DATETIME , new Date ( result . getLong ( fieldName ) / 1000L ) ) ; default : if ( "DECIMAL" . equals ( type . name ( ) ) ) { return Field . create ( Field . Type . DECIMAL , result . getDecimal ( fieldName ) ) ; } throw new StageException ( Errors . KUDU_10 , fieldName , type . getName ( ) ) ; } }
Create a field and assign a value off of RowResult.
@param result Result obtained from scan
@param fieldName Field name to create
@param type Kudu Type for the field
@return Generated field
@throws StageException
Create a field and assign a value off of RowResult .