{"record":{"id":"fe4392bc47f7b2db","repo":"pentaho/pentaho-kettle","slug":"the-type-of-the-field-0-is-different-of-the-replace-value","errorCode":null,"errorMessage":"The type of the field [{0}] is different of the replace value field [{1}]","messagePattern":"The type of the field \\[(.+?)\\] is different of the replace value field \\[(.+?)\\]","errorType":"exception","errorClass":"KettleStepException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/setvaluefield/SetValueField.java","lineNumber":107,"sourceCode":"        if ( Utils.isEmpty( sourceField ) ) {\n          throw new KettleStepException( BaseMessages.getString(\n            PKG, \"SetValueField.Log.ReplaceByValueFieldMissing\", \"\" + i ) );\n        }\n        data.indexOfReplaceByValue[i] = data.outputRowMeta.indexOfValue( sourceField );\n        if ( data.indexOfReplaceByValue[i] < 0 ) {\n          throw new KettleStepException( BaseMessages.getString(\n            PKG, \"SetValueField.Log.CouldNotFindFieldInRow\", sourceField ) );\n        }\n        // Compare fields type\n        ValueMetaInterface SourceValue = getInputRowMeta().getValueMeta( data.indexOfField[i] );\n        ValueMetaInterface ReplaceByValue = getInputRowMeta().getValueMeta( data.indexOfReplaceByValue[i] );\n\n        if ( SourceValue.getType() != ReplaceByValue.getType() ) {\n          String err =\n            BaseMessages.getString( PKG, \"SetValueField.Log.FieldsTypeDifferent\", SourceValue.getName()\n              + \" (\" + SourceValue.getTypeDesc() + \")\", ReplaceByValue.getName()\n              + \" (\" + ReplaceByValue.getTypeDesc() + \")\" );\n          throw new KettleStepException( err );\n        }\n      }\n    }\n    try {\n      for ( int i = 0; i < data.indexOfField.length; i++ ) {\n        r[data.indexOfField[i]] = r[data.indexOfReplaceByValue[i]];\n      }\n      putRow( data.outputRowMeta, r ); // copy row to output rowset(s);\n    } catch ( KettleException e ) {\n      boolean sendToErrorRow = false;\n      String errorMessage = null;\n\n      if ( getStepMeta().isDoingErrorHandling() ) {\n        sendToErrorRow = true;\n        errorMessage = e.toString();\n      } else {\n        logError( BaseMessages.getString( PKG, \"SetValueField.Log.ErrorInStep\", e.getMessage() ) );\n        setErrors( 1 );","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/setvaluefield/SetValueField.java#L89-L125","documentation":"Set Value Field performs a raw object copy r[field] = r[replaceBy] with no type conversion, so processRow enforces that both ValueMetaInterface entries have identical Kettle value types. When SourceValue.getType() != ReplaceByValue.getType() it throws KettleStepException listing both fields and their type descriptions (e.g. String vs Number).","triggerScenarios":"processRow compares getInputRowMeta().getValueMeta(indexOfField[i]).getType() with getValueMeta(indexOfReplaceByValue[i]).getType(); any type difference (String vs Integer, Date vs String, Number vs BigNumber, etc.) between the target field and the replace-by field triggers the throw.","commonSituations":"Copying a numeric column into a string column; upstream CSV/Text file input typed a column differently than the database field; a variable substitution changed which field is used, silently altering types; transformation edited after upstream type inference changed.","solutions":["Insert a 'Select values' step with a Metadata tab entry to convert the source field to the same type as the target before Set Value Field.","Or use 'Value Mapper' / 'Calculator' / 'User Defined Java Expression' to perform the copy with explicit conversion.","Align upstream typing (e.g. set the Text file input field format/type) so both fields share the same Kettle type.","Preview both fields and check their type descriptions in the message to confirm which side to convert."],"exampleFix":"// before: direct copy String -> Number fails\nr[idxAmount] = r[idxAmountStr];\n// after: convert with Select values (metadata) first\n// Select values: amount_str (String) -> amount_num (Number, format #.##)\nr[idxAmount] = r[idxAmountNum];","handlingStrategy":"validation","validationCode":"ValueMetaInterface source = rowMeta.getValueMeta(rowMeta.indexOfValue(srcField));\nValueMetaInterface target = rowMeta.getValueMeta(rowMeta.indexOfValue(tgtField));\nif (source.getType() != target.getType()) {\n  throw new IllegalStateException(\"Type mismatch: \" + source.getTypeDesc() + \" vs \" + target.getTypeDesc());\n}","typeGuard":null,"tryCatchPattern":"try {\n  trans.execute(null);\n} catch (KettleStepException e) {\n  log.error(\"Field type mismatch in Set Value Field: {}\", e.getMessage());\n}","preventionTips":["Insert a Select values (Metadata) conversion step when source/target types can differ","Explicitly set types in Text file / CSV input instead of relying on inference","Preview row metadata after any upstream change","Standardize column types across the pipeline (e.g. all amounts as Number)"],"tags":["kettle","type-mismatch","data-types","set-value-field"],"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"}