pentaho/pentaho-kettle · error · KettleException
Unable to find field name for formula [
Error message
Unable to find field name for formula [
What it means
KettleException thrown in Formula.calcFields() when a FormulaMetaFunction has an empty fieldName, i.e. the formula result has neither a new field name nor (checked earlier) a replace field. Every formula must produce output into a named field, so the step refuses to compute it.
Solutions
- Open the Formula step dialog and set the 'New field' name (or a 'Replace value' field) for every formula row.
- Remove any leftover blank formula rows.
- Validate the transformation (Ctrl+T) which surfaces empty formula field names at design time.
Example fix
// before new FormulaMetaFunction(fn, null, "NVL(x,0)", ...); // no field name // after new FormulaMetaFunction(fn, "defaulted_x", "NVL(x,0)", ...);
Defensive patterns
Strategy: validation
Validate before calling
if (Utils.isEmpty(fn.getFieldName()) && Utils.isEmpty(fn.getReplaceField())) {
throw new KettleException("Formula row needs a field name or replace field: " + fn.getFormula());
} Prevention
- Always fill 'New field' when adding a formula row
- Delete blank formula rows before saving
- Run transformation validation (Ctrl+T)
- Avoid hand-editing .ktr XML attributes
When it happens
Trigger: A formula row exists in the step meta whose 'New field' name is blank and 'Replace value' is also blank; this passes dialog edits but fails when the first row is processed.
Common situations: User added a formula row in the dialog but never filled in the field name; a transformation was hand-edited in XML and the field_name attribute was dropped; import from another environment lost attributes.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- No name was specified for result value #
- Unknown field specified to replace with a formula result: [
- A connection of type PALO is expected
- A server socket allocation always has to accompanied by…
- AccessInput.Exception.CouldnotFindField
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/760a6f5e35c5b2e8.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/formula/Formula.java:128
try {
Object[] outputRowData = RowDataUtil.createResizedCopy( r, data.outputRowMeta.size() );
int tempIndex = rowMeta.size();
// Assign this tempRowData to the formula context
//
data.context.setRowData( outputRowData );
// Initialize parsers etc. Only do it once.
//
if ( data.formulas == null ) {
// Create a set of LValues to put the parsed results in...
data.formulas = new org.pentaho.reporting.libraries.formula.Formula[meta.getFormula().length];
for ( int i = 0; i < meta.getFormula().length; i++ ) {
FormulaMetaFunction fn = meta.getFormula()[i];
if ( !Utils.isEmpty( fn.getFieldName() ) ) {
data.formulas[i] = data.createFormula( meta.getFormula()[i].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++ ) {
FormulaMetaFunction fn = meta.getFormula()[i];
if ( !Utils.isEmpty( fn.getFieldName() ) ) {
if ( data.formulas[i] == null ) {
data.formulas[i] = data.createFormula( meta.getFormula()[i].getFormula() );
}
// this is main part of all this step: calculate formula
Object formulaResult = data.formulas[i].evaluate();
if ( formulaResult instanceof LibFormulaErrorValue ) {
// inspect why it is happens to get clear error message.
throw new KettleException( "Error calculate formula. Formula "
+ fn.getFormula() + " output field: " + fn.getFieldName() + ", error is: " + formulaResult.toString() );View on GitHub (pinned to f3058517a1)