pentaho/pentaho-kettle · error · KettleValueException

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

Error message

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

What it means

ValueMetaBase.getBinary() does not define a byte representation for TYPE_NUMBER (double) values, so it throws KettleValueException. Only string-typed values can be converted to the internal binary-string representation; numeric fields must first be converted to strings.

Solutions

  1. Convert the number to a string first (str = vmNumber.getString(value)) and call getBinary on a TYPE_STRING meta.
  2. Change the field metadata to TYPE_STRING before requesting binary output.
  3. Use getString()/getString(row) with a format mask instead of byte-level access.
  4. Catch KettleValueException and handle numeric fields with explicit formatting.

Example fix

// before
ValueMetaInterface vm = new ValueMeta("n", ValueMetaInterface.TYPE_NUMBER);
byte[] b = vm.getBinary(3.14); // throws
// after
String s = vm.getString(3.14);
ValueMetaInterface vmStr = new ValueMeta("n", ValueMetaInterface.TYPE_STRING);
byte[] b = vmStr.getBinary(s);
Defensive patterns

Strategy: type-guard

Validate before calling

if (meta.getType() == ValueMetaInterface.TYPE_NUMBER) { throw new IllegalArgumentException("Field " + meta.getName() + " is numeric; 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) { byte[] b = vm.getString(value).getBytes(StandardCharsets.UTF_8); }

Prevention

When it happens

Trigger: Calling getBinary(object) on a value meta whose type is ValueMetaInterface.TYPE_NUMBER, e.g. in a custom step or output plugin that requests raw bytes of a numeric field.

Common situations: Text/binary file output steps misconfigured to emit number fields as binary; plugin code assuming getBinary is universal; serialization helpers applied to numeric fields.

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/5a336e3ab793b1e1. Report an issue: GitHub.

Appendix: source

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

            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:
        throw new KettleValueException( toString() + " : I don't know how to convert a boolean to binary." );
      case TYPE_SERIALIZABLE:
        throw new KettleValueException( toString() + " : I don't know how to convert a serializable to binary." );

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

  @Override
  public byte[] getBinaryString( Object object ) throws KettleValueException {
    // If the input is a binary string, we should return the exact same binary
    // object IF

View on GitHub (pinned to f3058517a1)