{"record":{"id":"4cbde9342d8ac0ff","repo":"pentaho/pentaho-kettle","slug":"calculator-log-unknowncalculationtype-fn-getcalctype","errorCode":null,"errorMessage":"Calculator.Log.UnknownCalculationType + fn.getCalcType()","messagePattern":"Calculator\\.Log\\.UnknownCalculationType \\+ fn\\.getCalcType\\(\\)","errorType":"exception","errorClass":"KettleValueException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/calculator/Calculator.java","lineNumber":611,"sourceCode":"            calcData[index] = ValueDataUtil.secondOfMinute( metaA, dataA );\n            resultType = CalculatorMetaFunction.calcDefaultResultType[calcType];\n            break;\n          case CalculatorMetaFunction.CALC_ADD_SECONDS: // Add B seconds to date field A\n            calcData[index] = ValueDataUtil.addSeconds( metaA, dataA, metaB, dataB );\n            resultType = CalculatorMetaFunction.calcDefaultResultType[calcType];\n            break;\n          case CalculatorMetaFunction.CALC_REMAINDER:\n            if ( targetMeta.getType() != metaA.getType() || targetMeta.getType() != metaB.getType() ) {\n              dataA = targetMeta.convertData( metaA, dataA );\n              metaA = targetMeta.clone();\n              dataB = targetMeta.convertData( metaB, dataB );\n              metaB = targetMeta.clone();\n            }\n            calcData[index] = ValueDataUtil.remainder( metaA, dataA, metaB, dataB );\n            resultType = targetMeta.getType();\n            break;\n          default:\n            throw new KettleValueException( BaseMessages.getString( PKG, \"Calculator.Log.UnknownCalculationType\" )\n              + fn.getCalcType() );\n        }\n\n        // If we don't have a target data type, throw an error.\n        // Otherwise the result is non-deterministic.\n        //\n        if ( targetMeta.getType() == ValueMetaInterface.TYPE_NONE ) {\n          throw new KettleValueException( BaseMessages.getString( PKG, \"Calculator.Log.NoType\" )\n            + ( i + 1 ) + \" : \" + fn.getFieldName() + \" = \" + fn.getCalcTypeDesc() + \" / \"\n            + fn.getCalcTypeLongDesc() );\n        }\n\n        // 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 {","sourceCodeStart":593,"sourceCodeEnd":629,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/calculator/Calculator.java#L593-L629","documentation":"calcFields switches over the calculation type; if fn.getCalcType() has no matching case, the default branch throws KettleValueException with the localized 'unknown calculation type' message plus the numeric calc type. This guards against corrupted or newer metadata containing calculation codes this PDI version does not know.","triggerScenarios":"calcFields encountering a CalculatorMetaFunction whose calcType integer is outside the known CALC_* range — typically metadata written by a newer PDI version, or an invalid calcType set programmatically.","commonSituations":"Opening a transformation created in a newer Pentaho version in an older engine; hand-editing kettle XML and putting a bad calc_type value; custom/patched builds.","solutions":["Open the transformation in the same or newer PDI version that defines the calculation type","Re-create the calculation using a supported type in the Calculator dialog","Check for calcType values set incorrectly in code and use the CalculatorMetaFunction.CALC_* constants"],"exampleFix":"// before\nfn.setCalcType(999); // unknown\n// after\nfn.setCalcType(CalculatorMetaFunction.CALC_ADDITION);","handlingStrategy":"try-catch","validationCode":"int calcType = fn.getCalcType();\nif (calcType < 0 || calcType > CalculatorMetaFunction.CALC_STRING_RIGHT_PAD /* max known */)\n  throw new IllegalArgumentException(\"Unknown calc type: \" + calcType);","typeGuard":null,"tryCatchPattern":"try { /* calcFields */ } catch (KettleValueException e) { if (e.getMessage().contains(\"Unknown calculation type\")) { /* open with a matching PDI version */ } throw e; }","preventionTips":["Keep PDI engine and Spoon/design tool versions aligned","Do not hand-edit kettle XML metadata calc_type values","Always use CalculatorMetaFunction.CALC_* constants in code"],"tags":["kettle","pdi","calculator","version-compatibility","enum"],"backgroundTag":"unsupported-enum-value","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"}