{"record":{"id":"77e3721e9a268231","repo":"pentaho/pentaho-kettle","slug":"i-don-t-know-how-to-convert-a-bignumber-to-binary","errorCode":null,"errorMessage":" : I don't know how to convert a bignumber to binary.","messagePattern":" : I don't know how to convert a bignumber to binary\\.","errorType":"exception","errorClass":"KettleValueException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java","lineNumber":2407,"sourceCode":"      case TYPE_DATE:\n        throw new KettleValueException( toString() + \" : I don't know how to convert a date to binary.\" );\n      case TYPE_STRING:\n        switch ( storageType ) {\n          case STORAGE_TYPE_NORMAL:\n            return convertStringToBinaryString( (String) object );\n          case STORAGE_TYPE_BINARY_STRING:\n            return (byte[]) object;\n          case STORAGE_TYPE_INDEXED:\n            return convertStringToBinaryString( (String) index[( (Integer) object ).intValue()] );\n          default:\n            throw new KettleValueException( toString() + \" : Unknown storage type \" + storageType + \" specified.\" );\n        }\n      case TYPE_NUMBER:\n        throw new KettleValueException( toString() + \" : I don't know how to convert a number to binary.\" );\n      case TYPE_INTEGER:\n        throw new KettleValueException( toString() + \" : I don't know how to convert an integer to binary.\" );\n      case TYPE_BIGNUMBER:\n        throw new KettleValueException( toString() + \" : I don't know how to convert a bignumber to binary.\" );\n      case TYPE_BOOLEAN:\n        throw new KettleValueException( toString() + \" : I don't know how to convert a boolean to binary.\" );\n      case TYPE_SERIALIZABLE:\n        throw new KettleValueException( toString() + \" : I don't know how to convert a serializable to binary.\" );\n\n      default:\n        throw new KettleValueException( toString() + \" : Unknown type \" + type + \" specified.\" );\n    }\n  }\n\n  @Override\n  public byte[] getBinaryString( Object object ) throws KettleValueException {\n    // If the input is a binary string, we should return the exact same binary\n    // object IF\n    // and only IF the formatting options for the storage metadata and this\n    // object are the same.\n    //\n    if ( isStorageBinaryString() && identicalFormat ) {","sourceCodeStart":2389,"sourceCodeEnd":2425,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java#L2389-L2425","documentation":"ValueMetaBase.getBinary() has no conversion from TYPE_BIGNUMBER (BigDecimal) to binary bytes and throws KettleValueException. Only string-typed values support byte conversion in this class; arbitrary-precision numbers must be converted to strings first.","triggerScenarios":"Calling getBinary(object) on a value meta whose type is ValueMetaInterface.TYPE_BIGNUMBER.","commonSituations":"Binary output of decimal/precision-critical fields; generic serialization code iterating row fields; output plugins expecting bytes for every type.","solutions":["Convert the BigDecimal to a string via getString() and call getBinary on a TYPE_STRING meta.","Change the field metadata to TYPE_STRING before binary output.","Use getString() with a decimal format mask instead.","Catch KettleValueException and handle bignumber fields explicitly."],"exampleFix":"// before\nValueMetaInterface vm = new ValueMeta(\"bn\", ValueMetaInterface.TYPE_BIGNUMBER);\nbyte[] b = vm.getBinary(bigDecimalValue); // throws\n// after\nString s = vm.getString(bigDecimalValue);\nValueMetaInterface vmStr = new ValueMeta(\"bn\", ValueMetaInterface.TYPE_STRING);\nbyte[] b = vmStr.getBinary(s);","handlingStrategy":"type-guard","validationCode":"if (meta.getType() == ValueMetaInterface.TYPE_BIGNUMBER) { throw new IllegalArgumentException(\"Field \" + meta.getName() + \" is a bignumber; convert to String before getBinary()\"); }","typeGuard":"boolean isBinaryReadable(ValueMetaInterface vm) { return vm.getType() == ValueMetaInterface.TYPE_STRING || vm.getType() == ValueMetaInterface.TYPE_BINARY; }","tryCatchPattern":"try { byte[] b = vm.getBinary(value); } catch (KettleValueException e) { byte[] b = vm.getString(value).getBytes(StandardCharsets.UTF_8); }","preventionTips":["Convert BigDecimal fields to strings before byte output.","Gate getBinary() on the declared value type.","Use format masks via getString() for decimal formatting.","Audit generic serializers to reject unsupported types up front."],"tags":["kettle","binary","type-mismatch"],"backgroundTag":"incompatible-source-type","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}