{"record":{"id":"3422d932c98ff073","repo":"pentaho/pentaho-kettle","slug":"i-don-t-know-how-to-convert-serializable-values-to-numbers","errorCode":null,"errorMessage":" : I don't know how to convert serializable values to numbers.","messagePattern":" : I don't know how to convert serializable values to numbers\\.","errorType":"exception","errorClass":"KettleValueException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java","lineNumber":2043,"sourceCode":"              return new Double( ( (BigDecimal) index[( (Integer) object ).intValue()] ).doubleValue() );\n            default:\n              throw new KettleValueException( toString() + \" : Unknown storage type \" + storageType + \" specified.\" );\n          }\n        case TYPE_BOOLEAN:\n          switch ( storageType ) {\n            case STORAGE_TYPE_NORMAL:\n              return convertBooleanToNumber( (Boolean) object );\n            case STORAGE_TYPE_BINARY_STRING:\n              return convertBooleanToNumber( (Boolean) convertBinaryStringToNativeType( (byte[]) object ) );\n            case STORAGE_TYPE_INDEXED:\n              return convertBooleanToNumber( (Boolean) index[( (Integer) object ).intValue()] );\n            default:\n              throw new KettleValueException( toString() + \" : Unknown storage type \" + storageType + \" specified.\" );\n          }\n        case TYPE_BINARY:\n          throw new KettleValueException( toString() + \" : I don't know how to convert binary values to numbers.\" );\n        case TYPE_SERIALIZABLE:\n          throw new KettleValueException( toString() + \" : I don't know how to convert serializable values to numbers.\" );\n        default:\n          throw new KettleValueException( toString() + \" : Unknown type \" + type + \" specified.\" );\n      }\n    } catch ( Exception e ) {\n      throw new KettleValueException( \"Unexpected conversion error while converting value [\" + toString()\n          + \"] to a Number\", e );\n    }\n  }\n\n  @Override\n  public Long getInteger( Object object ) throws KettleValueException {\n    try {\n      if ( isNull( object ) ) {\n        return null;\n      }\n      switch ( type ) {\n        case TYPE_INTEGER:\n          switch ( storageType ) {","sourceCodeStart":2025,"sourceCodeEnd":2061,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java#L2025-L2061","documentation":"ValueMetaBase.getNumber() throws this KettleValueException when the value metadata type is TYPE_SERIALIZABLE, i.e. the field holds an arbitrary Java Serializable object. Kettle has no generic mapping from an unknown Serializable object to a Double, so it refuses the conversion. The object must be narrowed to a concrete numeric/string type by the caller first.","triggerScenarios":"Calling ValueMeta.getNumber(Object) on a field whose valueMeta.getType() == ValueMetaInterface.TYPE_SERIALIZABLE (data is typically a java.lang.Object / Serializable instance).","commonSituations":"Streaming custom Java objects through transformations (e.g. job entries, user-defined Java class step outputs); Kettle internal fields such as batch/container objects marked Serializable; plugin code that copies rows into Number columns without converting the Serializable payload.","solutions":["Cast/narrow the Serializable object to its concrete class (e.g. Long, Double, String) and convert that explicitly before calling getNumber().","Replace the field's value metadata with the concrete real type (ValueMetaInteger/ValueMetaNumber) via a metadata/Select-values step so standard conversions apply.","If the Serializable wraps data you own, extract the numeric field from the object and put that in the row.","Catch KettleValueException and handle Serializable-typed columns separately in your row-processing code."],"exampleFix":"// before\nValueMetaInterface meta = new ValueMetaBase(\"obj\", ValueMetaInterface.TYPE_SERIALIZABLE);\nDouble n = meta.getNumber(rowData[0]); // throws\n\n// after\nObject raw = rowData[0];\nDouble n = (raw instanceof Number) ? ((Number) raw).doubleValue() : null;","handlingStrategy":"type-guard","validationCode":"if (meta.getType() == ValueMetaInterface.TYPE_SERIALIZABLE) {\n  throw new IllegalArgumentException(\"Field '\" + meta.getName() + \"' is SERIALIZABLE; narrow to a concrete type first\");\n}","typeGuard":"boolean isSerializable(ValueMetaInterface m) {\n  return m.getType() == ValueMetaInterface.TYPE_SERIALIZABLE;\n}","tryCatchPattern":"try {\n  Double n = meta.getNumber(value);\n} catch (KettleValueException e) {\n  log.warn(\"SERIALIZABLE field \" + meta.getName() + \" cannot be converted to Number\", e);\n}","preventionTips":["Avoid TYPE_SERIALIZABLE for fields that later feed numeric calculations; declare the real type up front.","Extract numeric members from custom Serializable objects before putting them into rows.","Use instanceof checks on raw row objects when metadata may be Serializable."],"tags":["kettle","type-conversion","serializable","value-metadata"],"backgroundTag":"type-mismatch","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"}