{"record":{"id":"b1095ab497eea5ac","repo":"pentaho/pentaho-kettle","slug":"i-don-t-know-how-to-convert-binary-values-to-booleans","errorCode":null,"errorMessage":" : I don't know how to convert binary values to booleans.","messagePattern":" : I don't know how to convert binary values to booleans\\.","errorType":"exception","errorClass":"KettleValueException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java","lineNumber":2291,"sourceCode":"            return convertNumberToBoolean( (Double) index[( (Integer) object ).intValue()] );\n          default:\n            throw new KettleValueException( toString() + \" : Unknown storage type \" + storageType + \" specified.\" );\n        }\n      case TYPE_BIGNUMBER:\n        switch ( storageType ) {\n          case STORAGE_TYPE_NORMAL:\n            return convertBigNumberToBoolean( (BigDecimal) object );\n          case STORAGE_TYPE_BINARY_STRING:\n            return convertBigNumberToBoolean( (BigDecimal) convertBinaryStringToNativeType( (byte[]) object ) );\n          case STORAGE_TYPE_INDEXED:\n            return convertBigNumberToBoolean( (BigDecimal) index[( (Integer) object ).intValue()] );\n          default:\n            throw new KettleValueException( toString() + \" : Unknown storage type \" + storageType + \" specified.\" );\n        }\n      case TYPE_DATE:\n        throw new KettleValueException( toString() + \" : I don't know how to convert date values to booleans.\" );\n      case TYPE_BINARY:\n        throw new KettleValueException( toString() + \" : I don't know how to convert binary values to booleans.\" );\n      case TYPE_SERIALIZABLE:\n        throw new KettleValueException( toString() + \" : I don't know how to convert serializable values to booleans.\" );\n      default:\n        throw new KettleValueException( toString() + \" : Unknown type \" + type + \" specified.\" );\n    }\n  }\n\n  @Override\n  public Date getDate( Object object ) throws KettleValueException {\n    if ( isNull( object ) ) {\n      return null;\n    }\n    switch ( type ) {\n      case TYPE_DATE:\n        switch ( storageType ) {\n          case STORAGE_TYPE_NORMAL:\n            return (Date) object;\n          case STORAGE_TYPE_BINARY_STRING:","sourceCodeStart":2273,"sourceCodeEnd":2309,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java#L2273-L2309","documentation":"This KettleValueException is thrown by ValueMetaBase.getBoolean(Object) when the value metadata's type is TYPE_BINARY. PDI has no defined rule for converting a raw byte[] to a Boolean, so instead of guessing it fails fast with a message prefixed by the field's toString() (name/type details). It is a programming/metadata-definition error, not a runtime data-quality issue.","triggerScenarios":"Calling getBoolean(object) (directly or via RowMeta.getBoolean/row-level getters) on a ValueMeta whose type was set to TYPE_BINARY, e.g. via new ValueMetaBinary(...), setValueType(ValueMetaInterface.TYPE_BINARY), or metadata read from a repository/ktr that declares the field as Binary.","commonSituations":"Reading CSV/database columns mapped as Binary then applying a Boolean output field in a transformation; custom plugin code calling row.getBoolean(index) without checking the field type; metadata imported from an older repository where the column was Binary.","solutions":["Change the field's value type to TYPE_BOOLEAN, TYPE_STRING, TYPE_INTEGER or TYPE_NUMBER before calling getBoolean (e.g. a 'Select values' / metadata edit step, or valueMeta.setValueType(ValueMetaInterface.TYPE_BOOLEAN) with an explicit conversion rule).","Convert the binary data yourself first (e.g. convertBinaryStringToNativeType or a string parse of \"Y\"/\"N\", \"true\"/\"false\") then read as the matching type.","Catch KettleValueException around the getBoolean call and handle the Binary field explicitly."],"exampleFix":"// before\nBoolean flag = valueMeta.getBoolean( rowData[i] ); // throws for TYPE_BINARY\n// after\nif ( valueMeta.getType() == ValueMetaInterface.TYPE_BINARY ) {\n  valueMeta.setValueType( ValueMetaInterface.TYPE_STRING ); // then convert explicitly\n}\nBoolean flag = valueMeta.getBoolean( rowData[i] );","handlingStrategy":"type-guard","validationCode":"if ( valueMeta.getType() == ValueMetaInterface.TYPE_BINARY ) {\n  throw new IllegalArgumentException( \"Field \" + valueMeta.getName() + \" is BINARY; cannot read as Boolean\" );\n}","typeGuard":"boolean readableAsBoolean( ValueMetaInterface vm ) {\n  int t = vm.getType();\n  return t == ValueMetaInterface.TYPE_BOOLEAN || t == ValueMetaInterface.TYPE_STRING\n      || t == ValueMetaInterface.TYPE_INTEGER || t == ValueMetaInterface.TYPE_NUMBER\n      || t == ValueMetaInterface.TYPE_BIGNUMBER;\n}","tryCatchPattern":"try {\n  Boolean b = valueMeta.getBoolean( row[i] );\n} catch ( KettleValueException e ) {\n  logError( \"Cannot read \" + valueMeta.getName() + \" as boolean: \" + e.getMessage() );\n  // handle Binary field explicitly\n}","preventionTips":["Check valueMeta.getType() before calling getBoolean.","Map Binary columns to Boolean via an explicit conversion step, never implicitly.","Declare Boolean fields as TYPE_BOOLEAN at the source of the transformation."],"tags":["kettle","value-conversion","boolean","unsupported-type"],"backgroundTag":"unsupported-operation","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"}