pentaho/pentaho-kettle · error · KettleStepException

Unable to find the second argument field

Error message

Unable to find the second argument field '{0} for calculation #{1}

What it means

For calculations that use a second argument, Calculator resolves fieldB against the input row metadata. If fieldB is non-empty but indexOfValue returns < 0, processRow throws KettleStepException 'Unable to find the second argument field ... for calculation #N'. As with field A, the message reports the calculated field's name, not the missing argument.

Solutions

  1. Correct 'Second argument field' in calculation #N to an existing input field
  2. Re-pick the field from the dropdown after previewing upstream output
  3. Restore the upstream step that produced the missing field

Example fix

// before
fn.setFieldB("vat_rate"); // upstream field is "VAT"
// after
fn.setFieldB("VAT");
Defensive patterns

Strategy: validation

Validate before calling

if (!Utils.isEmpty(fn.getFieldB()) && calcRowMeta.indexOfValue(fn.getFieldB()) < 0)
  throw new IllegalArgumentException("Calc fieldB not in input: " + fn.getFieldB());

Try / catch

catch (KettleStepException e) { /* open the calculation named in the message and fix field B */ throw e; }

Prevention

When it happens

Trigger: processRow init: function.getFieldB() is set but the named field is absent from data.getCalcRowMeta().

Common situations: Second argument field renamed or removed upstream; manual typo in the 'Second argument field' box; stale metadata after upstream edits.

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/a3df522411757210. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/calculator/Calculator.java:124

          if ( function.getCalcType() != CalculatorMetaFunction.CALC_CONSTANT ) {
            data.getFieldIndexes()[i].indexA = data.getCalcRowMeta().indexOfValue( function.getFieldA() );
            if ( data.getFieldIndexes()[i].indexA < 0 ) {
              // Nope: throw an exception
              throw new KettleStepException( "Unable to find the first argument field '"
                + function.getFieldName() + " for calculation #" + ( i + 1 ) );
            }
          } else {
            data.getFieldIndexes()[i].indexA = -1;
          }
        } else {
          throw new KettleStepException( "There is no first argument specified for calculated field #" + ( i + 1 ) );
        }

        if ( !Utils.isEmpty( function.getFieldB() ) ) {
          data.getFieldIndexes()[i].indexB = data.getCalcRowMeta().indexOfValue( function.getFieldB() );
          if ( data.getFieldIndexes()[i].indexB < 0 ) {
            // Nope: throw an exception
            throw new KettleStepException( "Unable to find the second argument field '"
              + function.getFieldName() + " for calculation #" + ( i + 1 ) );
          }
        }
        data.getFieldIndexes()[i].indexC = -1;
        if ( !Utils.isEmpty( function.getFieldC() ) ) {
          data.getFieldIndexes()[i].indexC = data.getCalcRowMeta().indexOfValue( function.getFieldC() );
          if ( data.getFieldIndexes()[i].indexC < 0 ) {
            // Nope: throw an exception
            throw new KettleStepException( "Unable to find the third argument field '"
              + function.getFieldName() + " for calculation #" + ( i + 1 ) );
          }
        }

        if ( function.isRemovedFromResult() ) {
          tempIndexes.add( getInputRowMeta().size() + i );
        }
      }

View on GitHub (pinned to f3058517a1)