pentaho/pentaho-kettle · error · KettleException

The input field for stats calc #

Error message

The input field for stats calc #{0}is not numeric.

What it means

UnivariateStats only supports numeric input. In processRow, after locating the source field's index, it checks inputFieldMeta.isNumeric(); if the field's ValueMetaInterface is not numeric (String, Date, Boolean, etc.) it throws this KettleException naming the calc index.

Solutions

  1. Convert the field to a numeric type upstream (e.g. Select values step with type Integer/Number, or String Operations/Value Mapper as appropriate)
  2. Check the incoming row's field type in Spoon (right-click > Show input fields)
  3. Fix the source step so it emits a numeric type
  4. If parsing strings, use a 'Calculator' or 'If field value is null'/conversion step to produce a Number

Example fix

// before: feeding String field directly
String amount -> UnivariateStats
// after: convert first
Select values step: amount String -> Number
Number amount -> UnivariateStats
Defensive patterns

Strategy: validation

Validate before calling

// Java: assert numeric input fields before execution
RowMetaInterface input = transMeta.getPrevStepFields( univariateStatsStepMeta );
for ( UnivariateStatsMetaFunction f : meta.getFieldDefs() ) {
  int idx = input.indexOfValue( f.getSourceFieldName() );
  if ( idx >= 0 && !input.getValueMeta( idx ).isNumeric() ) {
    throw new IllegalStateException( f.getSourceFieldName() + " must be numeric" );
  }
}

Type guard

boolean isNumericField(RowMetaInterface rowMeta, String name) {
  int idx = rowMeta.indexOfValue( name );
  return idx >= 0 && rowMeta.getValueMeta( idx ).isNumeric();
}

Try / catch

try {
  trans.execute( null );
} catch ( KettleException e ) {
  if ( e.getMessage().contains( "is not numeric" ) ) {
    // add an upstream type-conversion step
  }
  throw e;
}

Prevention

When it happens

Trigger: processRow's first-pass initialization encounters a configured stats field whose incoming row metadata reports a non-numeric type.

Common situations: Feeding a String-typed column (e.g. from CSV without conversion) into UnivariateStats; an upstream type change; forgetting a 'Select values'/'String to number' conversion step.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/univariatestats/UnivariateStats.java:145

        // check that this univariate stats computation has been
        // defined on an input field
        if ( !Utils.isEmpty( usmf.getSourceFieldName() ) ) {
          int fieldIndex = m_data.getInputRowMeta().indexOfValue( usmf.getSourceFieldName() );

          if ( fieldIndex < 0 ) {
            throw new KettleStepException( "Unable to find the specified fieldname '"
              + usmf.getSourceFieldName() + "' for stats calc #" + ( i + 1 ) );
          }

          FieldIndex tempData = m_data.getFieldIndexes()[ i ];

          tempData.m_columnIndex = fieldIndex;

          ValueMetaInterface inputFieldMeta = m_data.getInputRowMeta().getValueMeta( fieldIndex );

          // check the type of the input field
          if ( !inputFieldMeta.isNumeric() ) {
            throw new KettleException( "The input field for stats calc #" + ( i + 1 ) + "is not numeric." );
          }

          // finish initializing
          tempData.m_min = Double.MAX_VALUE;
          tempData.m_max = Double.MIN_VALUE;

          // set up caches if median/percentiles have been
          // requested

          if ( usmf.getCalcMedian() || usmf.getCalcPercentile() >= 0 ) {
            m_dataCache[ i ] = new ArrayList<Number>();
          }
        } else {
          throw new KettleException( "There is no input field specified for stats calc #" + ( i + 1 ) );
        }
      }
    } // end (if first)

View on GitHub (pinned to f3058517a1)