{"record":{"id":"ca76f699e54263d3","repo":"pentaho/pentaho-kettle","slug":"resulttype-resulttype-targetmeta-targetmeta-gettype","errorCode":null,"errorMessage":"resultType: \" + resultType + \"; targetMeta: \" + targetMeta.getType()","messagePattern":"resultType: \" \\+ resultType \\+ \"; targetMeta: \" \\+ targetMeta\\.getType\\(\\)","errorType":"exception","errorClass":"KettleValueException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/calculator/Calculator.java","lineNumber":642,"sourceCode":"        // Convert the data to the correct target data type.\n        //\n        if ( calcData[index] != null ) {\n          if ( targetMeta.getType() != resultType ) {\n            ValueMetaInterface resultMeta;\n            try {\n              // clone() is not necessary as one data instance belongs to one step instance and no race condition occurs\n              resultMeta = data.getValueMetaFor( resultType, \"result\" );\n            } catch ( Exception exception ) {\n              throw new KettleValueException( \"Error creating value\" );\n            }\n            resultMeta.setConversionMask( fn.getConversionMask() );\n            resultMeta.setGroupingSymbol( fn.getGroupingSymbol() );\n            resultMeta.setDecimalSymbol( fn.getDecimalSymbol() );\n            resultMeta.setCurrencySymbol( fn.getCurrencySymbol() );\n            try {\n              calcData[index] = targetMeta.convertData( resultMeta, calcData[index] );\n            } catch ( Exception ex ) {\n              throw new KettleValueException( \"resultType: \"\n                + resultType + \"; targetMeta: \" + targetMeta.getType(), ex );\n            }\n          }\n        }\n      }\n    }\n\n    // OK, now we should refrain from adding the temporary fields to the result.\n    // So we remove them.\n    //\n    return RowDataUtil.removeItems( calcData, data.getTempIndexes() );\n  }\n\n  @Override\n  public boolean init( StepMetaInterface smi, StepDataInterface sdi ) {\n    meta = (CalculatorMeta) smi;\n    data = (CalculatorData) sdi;\n","sourceCodeStart":624,"sourceCodeEnd":660,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/calculator/Calculator.java#L624-L660","documentation":"After calculating a value, Calculator converts it from the internal result type to the field's target type via targetMeta.convertData. Any exception there is wrapped in a KettleValueException whose message concatenates resultType and targetMeta.getType(), with the original exception as cause.","triggerScenarios":"calcData[index] holds a value of internal type resultType that cannot be converted to the target field's type (targetMeta.getType()), e.g. string that is not a number, or null/formatting incompatibility.","commonSituations":"Conversion mask mismatching data ('yyyy-MM-dd' vs 'dd/MM/yyyy'), non-numeric strings converted to Number via concatenation functions, locale/decimal-symbol settings that don't match the data.","solutions":["Read the chained cause exception for the exact parse/conversion failure","Fix the Calculator field's target type or conversion mask to match the actual data format","Set correct decimal/grouping/currency symbols on the field definition","Pre-normalize the input value (e.g. via a Select Values / String operations step) before the Calculator"],"exampleFix":"// before\nFieldname: amount, Calculator fn: A+B, Type: Number, ConversionMask: #,##0.00\n// data is '1.234,56' with default US symbols\n// after\nSet Decimal symbol: ',' and Grouping symbol: '.' on the Calculator field","handlingStrategy":"try-catch","validationCode":"// check the target type can hold the calculation result\nif (!isCompatible(calcResultType(fn), targetMeta.getType()))\n  logError(\"Type mismatch for calculator field \" + fn.getFieldName());","typeGuard":"boolean isNumeric(ValueMetaInterface vm) {\n  return vm != null && (vm.isNumber() || vm.isInteger() || vm.isBigNumber());\n}","tryCatchPattern":"try { calcData[index] = targetMeta.convertData(resultMeta, calcData[index]); }\ncatch (Exception ex) { throw new KettleValueException(\"Cannot convert \" + resultType + \" to \" + targetMeta.getType(), ex); }","preventionTips":["Match conversion masks to the actual data format","Set locale-correct decimal/grouping symbols","Pre-validate sample data with a preview run in Spoon"],"tags":["pdi","type-conversion","calculator"],"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"}