pentaho/pentaho-kettle · error · KettleValueException

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

Error message

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

What it means

Kettle cannot convert a value of TYPE_DATE into binary bytes in ValueMetaBase.getBinary(). Binary output is only supported for string-typed values (via convertStringToBinaryString); date values have no defined byte encoding, so KettleValueException is thrown. The field name is included via toString() to help locate the offending field.

Solutions

  1. Convert the date to a string first (formatDate or a Select Values type change to String), then call getBinary on the string-typed meta.
  2. Change the field metadata to TYPE_STRING before requesting binary data.
  3. Store the date as a long (getTime()) in an INTEGER field if byte-level representation is required.
  4. Catch KettleValueException and handle date fields with an explicit formatter instead of getBinary().

Example fix

// before
ValueMetaInterface vm = new ValueMeta("d", ValueMetaInterface.TYPE_DATE);
byte[] b = vm.getBinary(dateValue); // throws
// after
ValueMetaInterface vmStr = new ValueMeta("d", ValueMetaInterface.TYPE_STRING);
String s = vm.formatDate((Date) dateValue);
byte[] b = vmStr.getBinary(s);
Defensive patterns

Strategy: type-guard

Validate before calling

if (meta.getType() == ValueMetaInterface.TYPE_DATE) { throw new IllegalArgumentException("Field " + meta.getName() + " is a date; convert to String before getBinary()"); }

Type guard

boolean isBinaryReadable(ValueMetaInterface vm) { return vm.getType() == ValueMetaInterface.TYPE_STRING || vm.getType() == ValueMetaInterface.TYPE_BINARY; }

Try / catch

try { byte[] b = vm.getBinary(value); } catch (KettleValueException e) { String s = vm.getString(value); byte[] b = s != null ? s.getBytes() : null; }

Prevention

When it happens

Trigger: Calling getBinary(object) (or any code path requesting raw bytes, e.g. serialization helpers) on a value meta whose type is ValueMetaInterface.TYPE_DATE.

Common situations: Trying to write a date field out as a binary/text-file field expecting bytes; misconfigured Select Values or text output steps that cast fields to binary; plugin code assuming getBinary works for all types.

Understand the failure class

Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.

Related errors


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

Appendix: source

Thrown at core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java:2390

  @Override
  public byte[] getBinary( Object object ) throws KettleValueException {
    if ( object == null ) {
      return null;
    }
    switch ( type ) {
      case TYPE_BINARY:
        switch ( storageType ) {
          case STORAGE_TYPE_NORMAL:
            return (byte[]) object;
          case STORAGE_TYPE_BINARY_STRING:
            return (byte[]) object;
          case STORAGE_TYPE_INDEXED:
            return (byte[]) index[( (Integer) object ).intValue()];
          default:
            throw new KettleValueException( toString() + " : Unknown storage type " + storageType + " specified." );
        }
      case TYPE_DATE:
        throw new KettleValueException( toString() + " : I don't know how to convert a date to binary." );
      case TYPE_STRING:
        switch ( storageType ) {
          case STORAGE_TYPE_NORMAL:
            return convertStringToBinaryString( (String) object );
          case STORAGE_TYPE_BINARY_STRING:
            return (byte[]) object;
          case STORAGE_TYPE_INDEXED:
            return convertStringToBinaryString( (String) index[( (Integer) object ).intValue()] );
          default:
            throw new KettleValueException( toString() + " : Unknown storage type " + storageType + " specified." );
        }
      case TYPE_NUMBER:
        throw new KettleValueException( toString() + " : I don't know how to convert a number to binary." );
      case TYPE_INTEGER:
        throw new KettleValueException( toString() + " : I don't know how to convert an integer to binary." );
      case TYPE_BIGNUMBER:
        throw new KettleValueException( toString() + " : I don't know how to convert a bignumber to binary." );
      case TYPE_BOOLEAN:

View on GitHub (pinned to f3058517a1)