pentaho/pentaho-kettle · error · KettleValueException

: I don't know how to convert a binary value to timestamp.

Error message

 : I don't know how to convert a binary value to timestamp.

What it means

The TYPE_BINARY case of getTimestamp() always throws this KettleValueException: PDI does not define a conversion from raw binary (byte[]) values declared as TYPE_BINARY to Timestamp. Note this differs from STORAGE_TYPE_BINARY_STRING, which is a storage detail of convertible types and is supported — this throw applies only when the field's logical type is TYPE_BINARY.

Solutions

  1. Decode the binary yourself first (e.g. new String(bytes, encoding) then meta.convertStringToTimestamp(s)) and pass the result through the STRING branch of getTimestamp().
  2. Fix the field's declared type: if the bytes actually encode a timestamp string, set the meta type to TYPE_STRING (or TYPE_DATE) so the supported conversion path runs.
  3. Insert a conversion step (e.g. 'Calculator'/'User Defined Java Expression') upstream that turns the binary data into a parseable string/timestamp.
  4. Guard in code: check meta.getType() != TYPE_BINARY before calling getTimestamp() and skip or transform such fields.

Example fix

// before
Timestamp t = meta.getTimestamp( byteArray ); // TYPE_BINARY -> throws
// after
String s = new String( (byte[]) byteArray, StandardCharsets.UTF_8 );
Timestamp t = meta.convertStringToTimestamp( s );
Defensive patterns

Strategy: type-guard

Validate before calling

if ( meta.getType() == ValueMetaInterface.TYPE_BINARY ) {
  // decode bytes yourself; getTimestamp() will throw
}

Type guard

boolean isTimestampConvertible( ValueMetaInterface meta ) {
  switch ( meta.getType() ) {
    case ValueMetaInterface.TYPE_TIMESTAMP:
    case ValueMetaInterface.TYPE_DATE:
    case ValueMetaInterface.TYPE_STRING:
    case ValueMetaInterface.TYPE_NUMBER:
    case ValueMetaInterface.TYPE_INTEGER:
    case ValueMetaInterface.TYPE_BIGNUMBER:
      return true;
    default:
      return false;
  }
}

Try / catch

try {
  t = meta.getTimestamp( value );
} catch ( KettleValueException e ) {
  if ( e.getMessage().contains( "convert a binary value to timestamp" ) ) {
    String s = new String( (byte[]) value, StandardCharsets.UTF_8 );
    t = meta.convertStringToTimestamp( s );
  } else { throw e; }
}

Prevention

When it happens

Trigger: getTimestamp(object) called on a ValueMetaTimestamp where the value meta's type is TYPE_BINARY (binary-typed field), regardless of storage type.

Common situations: Reading raw binary database columns or files and then attempting timestamp conversion; a field type mis-set to TYPE_BINARY during metadata construction; plugins that emit binary fields consumed by timestamp-expecting steps.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/aff08127297b1d73. Report an issue: GitHub.

Appendix: source

Thrown at core/src/main/java/org/pentaho/di/core/row/value/ValueMetaTimestamp.java:188

            return convertIntegerToTimestamp( (Long) index[ ( (Integer) object ).intValue() ] );
          default:
            throw new KettleValueException( toString() + " : Unknown storage type " + storageType + " specified." );
        }
      case TYPE_BIGNUMBER:
        switch ( storageType ) {
          case STORAGE_TYPE_NORMAL:
            return convertBigNumberToTimestamp( (BigDecimal) object );
          case STORAGE_TYPE_BINARY_STRING:
            return convertBigNumberToTimestamp( (BigDecimal) convertBinaryStringToNativeType( (byte[]) object ) );
          case STORAGE_TYPE_INDEXED:
            return convertBigNumberToTimestamp( (BigDecimal) index[ ( (Integer) object ).intValue() ] );
          default:
            throw new KettleValueException( toString() + " : Unknown storage type " + storageType + " specified." );
        }
      case TYPE_BOOLEAN:
        throw new KettleValueException( toString() + " : I don't know how to convert a boolean to a timestamp." );
      case TYPE_BINARY:
        throw new KettleValueException( toString() + " : I don't know how to convert a binary value to timestamp." );
      case TYPE_SERIALIZABLE:
        throw new KettleValueException( toString()
          + " : I don't know how to convert a serializable value to timestamp." );

      default:
        throw new KettleValueException( toString() + " : Unknown type " + type + " specified." );
    }
  }

  public int compare( Object data1, Object data2 ) throws KettleValueException {
    Timestamp timestamp1 = getTimestamp( data1 );
    Timestamp timestamp2 = getTimestamp( data2 );
    int cmp = 0;
    if ( timestamp1 == null ) {
      if ( timestamp2 == null ) {
        cmp = 0;
      } else {
        cmp = -1;

View on GitHub (pinned to f3058517a1)