{"record":{"id":"523c36e7a56e327d","repo":"pentaho/pentaho-kettle","slug":"there-was-a-data-type-error-the-data-type-of-object-getclass-523c36","errorCode":null,"errorMessage":" : There was a data type error: the data type of \" + object.getClass().getName() + \" object [\" + object + \"] does not correspond to value meta [\" + toStringMeta() + \"]","messagePattern":" : There was a data type error: the data type of \" \\+ object\\.getClass\\(\\)\\.getName\\(\\) \\+ \" object \\[\" \\+ object \\+ \"\\] does not correspond to value meta \\[\" \\+ toStringMeta\\(\\) \\+ \"\\]","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"core/src/main/java/org/pentaho/di/core/row/value/ValueMetaTimestamp.java","lineNumber":610,"sourceCode":"            // Handle binary string content -- only when not NULL\n            // In this case, we opt not to convert anything at all for speed.\n            // That way, we can save on CPU power.\n            // Since the streams can be compressed, volume shouldn't be an issue\n            // at all.\n            //\n            writeBinaryString( outputStream, (byte[]) object );\n            break;\n\n          case STORAGE_TYPE_INDEXED:\n            writeInteger( outputStream, (Integer) object ); // just an index\n            break;\n\n          default:\n            throw new KettleFileException( toString() + \" : Unknown storage type \" + getStorageType() );\n        }\n      }\n    } catch ( ClassCastException e ) {\n      throw new RuntimeException( toString() + \" : There was a data type error: the data type of \"\n        + object.getClass().getName() + \" object [\" + object + \"] does not correspond to value meta [\"\n        + toStringMeta() + \"]\" );\n    } catch ( IOException e ) {\n      throw new KettleFileException( toString() + \" : Unable to write value timestamp data to output stream\", e );\n    } catch ( KettleValueException e ) {\n      throw new RuntimeException( toString() + \" : There was a data type error: the data type of \"\n        + object.getClass().getName() + \" object [\" + object + \"] does not correspond to value meta [\"\n        + toStringMeta() + \"]\" );\n    }\n  }\n\n  @Override\n  public Object readData( DataInputStream inputStream ) throws KettleFileException, KettleEOFException,\n    SocketTimeoutException {\n    try {\n      // Is the value NULL?\n      if ( inputStream.readBoolean() ) {\n        return null; // done","sourceCodeStart":592,"sourceCodeEnd":628,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/row/value/ValueMetaTimestamp.java#L592-L628","documentation":"A RuntimeException thrown by ValueMetaTimestamp.writeData when a ClassCastException (or KettleValueException) occurs while writing — i.e. the runtime object is not the type the value metadata declares (e.g. a String where a Timestamp is expected).","triggerScenarios":"Writing a row whose field holds a String/Date/byte[] while the meta says Timestamp with a storage type that triggers a cast, e.g. STORAGE_TYPE_INDEXED with a non-Integer object, or normal storage with a non-Timestamp object.","commonSituations":"Row layout drift between transforms (field type changed upstream), heterogeneous input files, incorrectly typed data injected via custom code.","solutions":["Align the row metadata with actual object types (use RowMetaUtil / verify with a 'Verify rows' pattern)","Convert the value before writing: valueMeta.convertData(sourceMeta, data)","Inspect object.getClass() at the write site and fix the producing transform"],"exampleFix":"// before\nrow[0] = \"2024-01-05 10:00:00\"; // meta says Timestamp\n// after\nrow[0] = tsMeta.convertData(stringMeta, row[0]); // now a Timestamp","handlingStrategy":"type-guard","validationCode":"if (object != null && !(object instanceof java.sql.Timestamp)\n && valueMeta.getStorageType() == ValueMetaInterface.STORAGE_TYPE_NORMAL) {\n  object = valueMeta.convertData(dateMeta, object);\n}","typeGuard":"boolean isTimestampData(ValueMetaInterface vm, Object o) {\n  if (o == null) return true;\n  switch (vm.getStorageType()) {\n    case ValueMetaInterface.STORAGE_TYPE_NORMAL: return o instanceof java.sql.Timestamp;\n    case ValueMetaInterface.STORAGE_TYPE_INDEXED: return o instanceof Integer;\n    case ValueMetaInterface.STORAGE_TYPE_BINARY_STRING: return o instanceof byte[];\n    default: return false;\n  }\n}","tryCatchPattern":"try {\n  meta.writeData(out, object);\n} catch (RuntimeException e) {\n  if (e.getMessage().contains(\"data type error\")) {\n    object = meta.convertData(sourceMeta, object);\n    meta.writeData(out, object);\n  } else throw e;\n}","preventionTips":["Keep row metadata and actual object types in sync through the whole pipeline","Convert at transform boundaries, never assume the previous step's types","Run pipelines in development with data-type verification enabled"],"tags":["pdi","type-mismatch","serialization","row-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"}