pentaho/pentaho-kettle · error · KettleException

Unable to find field name for formula

Error message

Unable to find field name for formula [{formula}]

What it means

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.

Solutions

  1. Check the formula text for typos and use the Fields list/autocomplete in the dialog instead of typing names.
  2. Verify upstream steps still produce the referenced field (use 'Input' preview / row sample).
  3. Adjust the formula to use only existing fields, or add the field upstream.
  4. Re-save the step after upstream changes so row metadata is re-resolved.

Example fix

// before
formula: customer_nam + " X"
// after
formula: customer_name + " X"
Defensive patterns

Strategy: validation

Validate before calling

// Verify every identifier used in the formula exists in the stream
for (String fieldName : extractIdentifiers(fn.getFormula())) {
  if (inputRowMeta.searchValueMeta(fieldName) == null) {
    throw new IllegalStateException("Formula references unknown field: " + fieldName);
  }
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/05e80873c8a7373b. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/janino/Janino.java:166

              parameterTypes.add( valueMeta.getNativeDataTypeClass() );
              parameterNames.add( valueMeta.getName() );
            }
          }

          JaninoMetaFunction fn = meta.getFormula()[m];
          if ( !Utils.isEmpty( fn.getFieldName() ) ) {

            // Create the expression evaluator: is relatively slow so we do it only for the first row...
            //
            data.expressionEvaluators[m] = new ExpressionEvaluator();
            data.expressionEvaluators[m].setParameters(
              parameterNames.toArray( new String[parameterNames.size()] ), parameterTypes
                .toArray( new Class<?>[parameterTypes.size()] ) );
            data.expressionEvaluators[m].setReturnType( Object.class );
            data.expressionEvaluators[m].setThrownExceptions( new Class<?>[] { Exception.class } );
            data.expressionEvaluators[m].cook( fn.getFormula() );
          } else {
            throw new KettleException( "Unable to find field name for formula ["
              + Const.NVL( fn.getFormula(), "" ) + "]" );
          }
        }
      }

      for ( int i = 0; i < meta.getFormula().length; i++ ) {
        List<Integer> argumentIndexes = data.argumentIndexes.get( i );

        // This method can only accept the specified number of values...
        //
        Object[] argumentData = new Object[argumentIndexes.size()];
        for ( int x = 0; x < argumentIndexes.size(); x++ ) {
          int index = argumentIndexes.get( x );
          ValueMetaInterface outputValueMeta = data.outputRowMeta.getValueMeta( index );
          argumentData[x] = outputValueMeta.convertToNormalStorageType( outputRowData[index] );
        }

        Object formulaResult = data.expressionEvaluators[i].evaluate( argumentData );

View on GitHub (pinned to f3058517a1)