{"record":{"id":"e785cd36cd52047d","repo":"pentaho/pentaho-kettle","slug":"there-was-a-data-type-error-the-data-type-of-object-getclass","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":"KettleValueException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java","lineNumber":1942,"sourceCode":"            case STORAGE_TYPE_INDEXED:\n              string = object == null ? null : index[( (Integer) object ).intValue()].toString();\n              break; // just go for the default toString()\n            default:\n              throw new KettleValueException( toString() + \" : Unknown storage type \" + storageType + \" specified.\" );\n          }\n          break;\n\n        default:\n          throw new KettleValueException( toString() + \" : Unknown type \" + type + \" specified.\" );\n      }\n\n      if ( isOutputPaddingEnabled() && getLength() > 0 ) {\n        string = ValueDataUtil.rightPad( string, getLength() );\n      }\n\n      return string;\n    } catch ( ClassCastException e ) {\n      throw new KettleValueException( 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  protected String trim( String string ) {\n    switch ( getTrimType() ) {\n      case TRIM_TYPE_NONE:\n        break;\n      case TRIM_TYPE_RIGHT:\n        string = Const.rtrim( string );\n        break;\n      case TRIM_TYPE_LEFT:\n        string = Const.ltrim( string );\n        break;\n      case TRIM_TYPE_BOTH:\n        string = Const.trim( string );\n        break;","sourceCodeStart":1924,"sourceCodeEnd":1960,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java#L1924-L1960","documentation":"Thrown by ValueMetaBase.getString(Object) when the underlying Java object does not match the value meta's declared type: the per-type switch performed an illegal cast (caught ClassCastException) and is rethrown as a KettleValueException naming both the object's actual class and the expected metadata. It means row data and row metadata disagree.","triggerScenarios":"Calling getString() on a row value whose runtime class differs from the meta (e.g. meta says TYPE_INTEGER (Long) but the field holds a String or BigDecimal; or a storageType of INDEXED where object is not an Integer index).","commonSituations":"Steps that write rows without creating matching row metadata (RowMetaAndData misuse); mixing rows from two different row sets after a join/merge; changing a field type upstream without adjusting downstream metadata; hand-populating Object[] rows.","solutions":["Align row metadata with actual data: regenerate RowMeta for the stream (e.g. setInputRowMeta from real row layout)","Convert the value explicitly first: ValueDataUtil or valueMeta.convertData(expectedMeta, object)","Inspect the exception text — it prints the object's class vs toStringMeta() — and fix the step producing the mismatched field"],"exampleFix":"// before\n// meta declares TYPE_INTEGER but value is a String\nString s = valueMeta.getInteger( \"123\" ); // throws\n// after\nObject converted = valueMeta.convertData( new ValueMetaString( \"col\" ), rawValue );\nString s = valueMeta.getString( converted );","handlingStrategy":"try-catch","validationCode":"Object v = row[dataIndex];\nif ( meta.isInteger() && !( v instanceof Long || v == null ) ) {\n  v = Long.valueOf( v.toString() );\n}","typeGuard":"boolean matchesMeta( ValueMetaInterface m, Object v ) {\n  if ( v == null ) return true;\n  if ( m.isString() ) return v instanceof String;\n  if ( m.isInteger() ) return v instanceof Long;\n  if ( m.isNumber() ) return v instanceof Double;\n  if ( m.isBigNumber() ) return v instanceof java.math.BigDecimal;\n  if ( m.isDate() ) return v instanceof java.util.Date;\n  if ( m.isBoolean() ) return v instanceof Boolean;\n  if ( m.isBinary() ) return v instanceof byte[];\n  return true;\n}","tryCatchPattern":"try { return meta.getString( value ); }\ncatch ( KettleValueException e ) {\n  log.error( \"Row/meta mismatch: {}\", e.getMessage() );\n  return meta.getString( meta.convertData( new ValueMetaString( meta.getName() ), value ) );\n}","preventionTips":["Verify row data layout matches the RowMeta at every step boundary","Use RowMetaAndData helpers instead of raw Object[] assembly","Convert values explicitly with convertData() before type-specific getters","Regenerate downstream RowMeta when an upstream field type changes"],"tags":["kettle","type-mismatch","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"}