{"record":{"id":"05e80873c8a7373b","repo":"pentaho/pentaho-kettle","slug":"unable-to-find-field-name-for-formula-formula","errorCode":null,"errorMessage":"Unable to find field name for formula [{formula}]","messagePattern":"Unable to find field name for formula \\[(.+?)\\]","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/janino/Janino.java","lineNumber":166,"sourceCode":"              parameterTypes.add( valueMeta.getNativeDataTypeClass() );\n              parameterNames.add( valueMeta.getName() );\n            }\n          }\n\n          JaninoMetaFunction fn = meta.getFormula()[m];\n          if ( !Utils.isEmpty( fn.getFieldName() ) ) {\n\n            // Create the expression evaluator: is relatively slow so we do it only for the first row...\n            //\n            data.expressionEvaluators[m] = new ExpressionEvaluator();\n            data.expressionEvaluators[m].setParameters(\n              parameterNames.toArray( new String[parameterNames.size()] ), parameterTypes\n                .toArray( new Class<?>[parameterTypes.size()] ) );\n            data.expressionEvaluators[m].setReturnType( Object.class );\n            data.expressionEvaluators[m].setThrownExceptions( new Class<?>[] { Exception.class } );\n            data.expressionEvaluators[m].cook( fn.getFormula() );\n          } else {\n            throw new KettleException( \"Unable to find field name for formula [\"\n              + Const.NVL( fn.getFormula(), \"\" ) + \"]\" );\n          }\n        }\n      }\n\n      for ( int i = 0; i < meta.getFormula().length; i++ ) {\n        List<Integer> argumentIndexes = data.argumentIndexes.get( i );\n\n        // This method can only accept the specified number of values...\n        //\n        Object[] argumentData = new Object[argumentIndexes.size()];\n        for ( int x = 0; x < argumentIndexes.size(); x++ ) {\n          int index = argumentIndexes.get( x );\n          ValueMetaInterface outputValueMeta = data.outputRowMeta.getValueMeta( index );\n          argumentData[x] = outputValueMeta.convertToNormalStorageType( outputRowData[index] );\n        }\n\n        Object formulaResult = data.expressionEvaluators[i].evaluate( argumentData );","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/janino/Janino.java#L148-L184","documentation":"Thrown by the Janino step's calcFields when a formula references a field name that cannot be found in the incoming row metadata while compiling the expression evaluator. The formula text names a column absent from the row at runtime.","triggerScenarios":"During processing, a JaninoMetaFunction whose formula text contains a field identifier with no matching entry in the input row's value metadata (field lookup returned null before cooking the expression).","commonSituations":"Typo in a field name inside the formula; upstream field removed/renamed after the formula was written; locale/encoding differences in field names; running against a different input file layout than designed.","solutions":["Check the formula text for typos and use the Fields list/autocomplete in the dialog instead of typing names.","Verify upstream steps still produce the referenced field (use 'Input' preview / row sample).","Adjust the formula to use only existing fields, or add the field upstream.","Re-save the step after upstream changes so row metadata is re-resolved."],"exampleFix":"// before\nformula: customer_nam + \" X\"\n// after\nformula: customer_name + \" X\"","handlingStrategy":"validation","validationCode":"// Verify every identifier used in the formula exists in the stream\nfor (String fieldName : extractIdentifiers(fn.getFormula())) {\n  if (inputRowMeta.searchValueMeta(fieldName) == null) {\n    throw new IllegalStateException(\"Formula references unknown field: \" + fieldName);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Insert field names via the Formula editor's field list/autocomplete.","Preview upstream rows to confirm field names before writing formulas.","Watch for renames in upstream steps during code review of .ktr diffs."],"tags":["kettle","formula","field-mapping"],"backgroundTag":"resource-not-found","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"}