pentaho/pentaho-kettle · error · KettleValueException
Please specify a Boolean type for field [
Error message
Please specify a Boolean type for field [
What it means
KettleValueException thrown in Formula.calcFields() when the formula evaluates to a Boolean but the output field's declared value type is not ValueMetaInterface.TYPE_BOOLEAN. The step will not coerce Boolean results to String/Number automatically.
Solutions
- Set the output field Type to Boolean in the Formula step dialog.
- Or convert the result to a non-boolean explicitly: IF([a]>10; 1; 0) with type Number, or IF([a]>10;"Y";"N") with type String.
- Re-run the step's field-type inference after editing formulas.
Example fix
// before fn.setValueType(ValueMetaInterface.TYPE_STRING); // formula: [x]>0 // after fn.setValueType(ValueMetaInterface.TYPE_BOOLEAN);
Defensive patterns
Strategy: validation
Validate before calling
if (result instanceof Boolean && fn.getValueType() != ValueMetaInterface.TYPE_BOOLEAN) {
fn.setValueType(ValueMetaInterface.TYPE_BOOLEAN);
} Type guard
if (result instanceof Boolean && fn.getValueType() != ValueMetaInterface.TYPE_BOOLEAN) { throw new IllegalArgumentException("Declare Boolean type for " + fn.getFieldName()); } Prevention
- Set output Type=Boolean for comparison formulas
- Use IF(cond;1;0) with Number type if you need numeric output
- Update declared types whenever the formula result type changes
When it happens
Trigger: A formula such as "[a] > 10" or a comparison returning Boolean is assigned to a field whose Type column is String, Number, Integer, etc.
Common situations: Adding a boolean filter column with output type left as default String; changing a formula from numeric to comparison without updating the declared output type.
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
- : I don't know how to convert a boolean to a date.
- Janino.Error.ValueTypeMismatch
- Please specify a Binary type for field [
- AuthenticationManager.ConsumedTypeError
- AvroInput.Error.UnexpectedRecordFieldTypeAtNonExpansionPoint
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/197367314d918ee1.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/formula/Formula.java:180
data.returnType[i] = FormulaData.RETURN_TYPE_DATE;
fn.setNeedDataConversion( fn.getValueType() != ValueMetaInterface.TYPE_DATE );
} else if ( formulaResult instanceof BigDecimal ) {
data.returnType[i] = FormulaData.RETURN_TYPE_BIGDECIMAL;
fn.setNeedDataConversion( fn.getValueType() != ValueMetaInterface.TYPE_BIGNUMBER );
} else if ( formulaResult instanceof Number ) {
data.returnType[i] = FormulaData.RETURN_TYPE_NUMBER;
fn.setNeedDataConversion( fn.getValueType() != ValueMetaInterface.TYPE_NUMBER );
// this types we will not make attempt to auto-convert
} else if ( formulaResult instanceof byte[] ) {
data.returnType[i] = FormulaData.RETURN_TYPE_BYTE_ARRAY;
if ( fn.getValueType() != ValueMetaInterface.TYPE_BINARY ) {
throw new KettleValueException( "Please specify a Binary type for field ["
+ fn.getFieldName() + "] as a result of formula [" + fn.getFormula() + "]" );
}
} else if ( formulaResult instanceof Boolean ) {
data.returnType[i] = FormulaData.RETURN_TYPE_BOOLEAN;
if ( fn.getValueType() != ValueMetaInterface.TYPE_BOOLEAN ) {
throw new KettleValueException( "Please specify a Boolean type for field ["
+ fn.getFieldName() + "] as a result of formula [" + fn.getFormula() + "]" );
}
} else {
data.returnType[i] = FormulaData.RETURN_TYPE_STRING;
fn.setNeedDataConversion( fn.getValueType() != ValueMetaInterface.TYPE_STRING );
}
}
int realIndex = ( data.replaceIndex[i] < 0 ) ? tempIndex++ : data.replaceIndex[i];
outputRowData[realIndex] = getReturnValue( formulaResult, data.returnType[i], realIndex, fn );
}
}
return outputRowData;
} catch ( Throwable e ) {
throw new KettleValueException( e );
}
}View on GitHub (pinned to f3058517a1)