{"record":{"id":"df9eb47ce200cc0f","repo":"pentaho/pentaho-kettle","slug":"there-is-no-first-argument-specified-for-calculated-field-0","errorCode":null,"errorMessage":"There is no first argument specified for calculated field #{0}","messagePattern":"There is no first argument specified for calculated field #(.+?)","errorType":"validation","errorClass":"KettleStepException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/calculator/Calculator.java","lineNumber":117,"sourceCode":"          }\n        } else {\n          throw new KettleStepException( BaseMessages.getString( PKG, \"Calculator.Error.NoNameField\", \"\"\n            + ( i + 1 ) ) );\n        }\n\n        if ( !Utils.isEmpty( function.getFieldA() ) ) {\n          if ( function.getCalcType() != CalculatorMetaFunction.CALC_CONSTANT ) {\n            data.getFieldIndexes()[i].indexA = data.getCalcRowMeta().indexOfValue( function.getFieldA() );\n            if ( data.getFieldIndexes()[i].indexA < 0 ) {\n              // Nope: throw an exception\n              throw new KettleStepException( \"Unable to find the first argument field '\"\n                + function.getFieldName() + \" for calculation #\" + ( i + 1 ) );\n            }\n          } else {\n            data.getFieldIndexes()[i].indexA = -1;\n          }\n        } else {\n          throw new KettleStepException( \"There is no first argument specified for calculated field #\" + ( i + 1 ) );\n        }\n\n        if ( !Utils.isEmpty( function.getFieldB() ) ) {\n          data.getFieldIndexes()[i].indexB = data.getCalcRowMeta().indexOfValue( function.getFieldB() );\n          if ( data.getFieldIndexes()[i].indexB < 0 ) {\n            // Nope: throw an exception\n            throw new KettleStepException( \"Unable to find the second argument field '\"\n              + function.getFieldName() + \" for calculation #\" + ( i + 1 ) );\n          }\n        }\n        data.getFieldIndexes()[i].indexC = -1;\n        if ( !Utils.isEmpty( function.getFieldC() ) ) {\n          data.getFieldIndexes()[i].indexC = data.getCalcRowMeta().indexOfValue( function.getFieldC() );\n          if ( data.getFieldIndexes()[i].indexC < 0 ) {\n            // Nope: throw an exception\n            throw new KettleStepException( \"Unable to find the third argument field '\"\n              + function.getFieldName() + \" for calculation #\" + ( i + 1 ) );\n          }","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/calculator/Calculator.java#L99-L135","documentation":"Every calculation that references a first argument must actually specify one: if function.getFieldA() is empty/null and the calc type is not CALC_CONSTANT, processRow throws KettleStepException 'There is no first argument specified for calculated field #N'. This is a configuration completeness check distinct from the field-not-found check.","triggerScenarios":"processRow init: a calculation type that requires field A (any non-constant type) has an empty getFieldA().","commonSituations":"Choosing a two-argument calculation (e.g. A+B, A-B) but leaving the first argument blank in the dialog; building meta programmatically and omitting fieldA.","solutions":["Set the 'First argument field' for calculation #N in the Calculator dialog","Switch the calculation type to a constant or one-argument type if field A is genuinely not needed","Remove the incomplete calculation row"],"exampleFix":"// before\nfn = new CalculatorMetaFunction(\"total\", CALC_SUM, null, \"b\", null, ...); // fieldA missing\n// after\nfn = new CalculatorMetaFunction(\"total\", CALC_SUM, \"a\", \"b\", null, ...);","handlingStrategy":"validation","validationCode":"if (fn.getCalcType() != CALC_CONSTANT && Utils.isEmpty(fn.getFieldA()))\n  throw new IllegalArgumentException(\"Calc # requires a first argument\");","typeGuard":null,"tryCatchPattern":"catch (KettleStepException e) { if (e.getMessage().contains(\"no first argument\")) { /* set fieldA or change calc type */ } throw e; }","preventionTips":["Match the number of arguments to the chosen calculation type (A, A+B, A+B+C)","Use CALC_CONSTANT only when supplying a constant value","Review the Calculator grid for blank argument cells before saving"],"tags":["kettle","pdi","calculator","missing-argument"],"backgroundTag":"missing-required-argument","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"}