{"record":{"id":"ec60cc1d00b34c50","repo":"pentaho/pentaho-kettle","slug":"unable-to-find-the-specified-fieldname-0-for-stats-calc-1","errorCode":null,"errorMessage":"Unable to find the specified fieldname '{0}' for stats calc #{1}","messagePattern":"Unable to find the specified fieldname '(.+?)' for stats calc #(.+?)","errorType":"exception","errorClass":"KettleStepException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/univariatestats/UnivariateStats.java","lineNumber":133,"sourceCode":"      // Initialize the step meta data\n      FieldIndex[] fi = new FieldIndex[ m_meta.getNumFieldsToProcess() ];\n\n      m_data.setFieldIndexes( fi );\n\n      // allocate the field indexes in the data class and meta stats functions\n      // in the step meta\n      for ( int i = 0; i < m_meta.getNumFieldsToProcess(); i++ ) {\n        UnivariateStatsMetaFunction usmf = m_meta.getInputFieldMetaFunctions()[ i ];\n        //CHECKSTYLE:Indentation:OFF\n        m_data.getFieldIndexes()[ i ] = new FieldIndex();\n\n        // check that this univariate stats computation has been\n        // defined on an input field\n        if ( !Utils.isEmpty( usmf.getSourceFieldName() ) ) {\n          int fieldIndex = m_data.getInputRowMeta().indexOfValue( usmf.getSourceFieldName() );\n\n          if ( fieldIndex < 0 ) {\n            throw new KettleStepException( \"Unable to find the specified fieldname '\"\n              + usmf.getSourceFieldName() + \"' for stats calc #\" + ( i + 1 ) );\n          }\n\n          FieldIndex tempData = m_data.getFieldIndexes()[ i ];\n\n          tempData.m_columnIndex = fieldIndex;\n\n          ValueMetaInterface inputFieldMeta = m_data.getInputRowMeta().getValueMeta( fieldIndex );\n\n          // check the type of the input field\n          if ( !inputFieldMeta.isNumeric() ) {\n            throw new KettleException( \"The input field for stats calc #\" + ( i + 1 ) + \"is not numeric.\" );\n          }\n\n          // finish initializing\n          tempData.m_min = Double.MAX_VALUE;\n          tempData.m_max = Double.MIN_VALUE;\n","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/univariatestats/UnivariateStats.java#L115-L151","documentation":"The UnivariateStats step computes statistics (mean, median, stddev, etc.) over configured input fields. During processRow initialization it looks up each stats definition's source field in the incoming row metadata; if indexOfValue returns -1 the step aborts with this KettleStepException naming the missing field and calc index.","triggerScenarios":"processRow (first pass) finds a UnivariateStatsMetaFunction whose sourceFieldName is non-empty but absent from m_data.getInputRowMeta() — i.e. the configured field is not produced by the preceding step.","commonSituations":"Upstream step renamed or removed the field; field name typo in the step config; transformation edited so the field no longer flows into UnivariateStats.","solutions":["Open the UnivariateStats step and verify each stats calc's source field name against the incoming stream","Use the 'Get fields' button in the step dialog to re-populate valid field names","Fix or add the upstream step that should produce the field","Re-check the hop is connected to the step that emits the field"],"exampleFix":"// before (config referencing removed field)\nsourceFieldName=\"amount_old\"\n// after\nsourceFieldName=\"amount\"","handlingStrategy":"validation","validationCode":"// Java: verify configured source fields exist in the incoming stream before running\nRowMetaInterface input = transMeta.getPrevStepFields( univariateStatsStepMeta );\nfor ( UnivariateStatsMetaFunction f : meta.getFieldDefs() ) {\n  if ( !Utils.isEmpty( f.getSourceFieldName() ) && input.indexOfValue( f.getSourceFieldName() ) < 0 ) {\n    throw new IllegalStateException( \"Field \" + f.getSourceFieldName() + \" not in input stream\" );\n  }\n}","typeGuard":"boolean fieldExists(RowMetaInterface rowMeta, String name) {\n  return rowMeta != null && name != null && rowMeta.indexOfValue( name ) >= 0;\n}","tryCatchPattern":"try {\n  trans.execute( null );\n} catch ( KettleStepException e ) {\n  if ( e.getMessage().startsWith( \"Unable to find the specified fieldname\" ) ) {\n    // fix the UnivariateStats field configuration\n  }\n  throw e;\n}","preventionTips":["Use 'Get fields' in the step dialog instead of typing field names","Re-check step configs after renaming upstream fields","Run Spoon's step check results before executing"],"tags":["kettle","field-lookup","runtime","univariate-stats"],"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"}