{"record":{"id":"b3529f84bd793996","repo":"pentaho/pentaho-kettle","slug":"function-exp-only-works-with-a-number","errorCode":null,"errorMessage":"Function EXP only works with a number","messagePattern":"Function EXP only works with a number","errorType":"exception","errorClass":"KettleValueException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/compatibility/Value.java","lineNumber":2470,"sourceCode":"\n    if ( isNumeric() ) {\n      setValue( Math.cos( getNumber() ) );\n    } else {\n      throw new KettleValueException( \"Function COS only works with a number\" );\n    }\n    return this;\n  }\n\n  // implement the EXP function, arguments in args[]\n  public Value exp() throws KettleValueException {\n    if ( isNull() ) {\n      return this;\n    }\n\n    if ( isNumeric() ) {\n      setValue( Math.exp( getNumber() ) );\n    } else {\n      throw new KettleValueException( \"Function EXP only works with a number\" );\n    }\n    return this;\n  }\n\n  // implement the FLOOR function, arguments in args[]\n  public Value floor() throws KettleValueException {\n    if ( isNull() ) {\n      return this;\n    }\n\n    if ( isNumeric() ) {\n      setValue( Math.floor( getNumber() ) );\n    } else {\n      throw new KettleValueException( \"Function FLOOR only works with a number\" );\n    }\n    return this;\n  }\n","sourceCodeStart":2452,"sourceCodeEnd":2488,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/compatibility/Value.java#L2452-L2488","documentation":"The exp() method of Kettle's legacy Value class raises e to the power of the value using Math.exp. It throws this KettleValueException when the Value is not numeric, since Math.exp requires a double argument. This is the legacy Value class's runtime type contract for math functions.","triggerScenarios":"Calling Value.exp() on a String/Date/Boolean-typed Value, e.g. exponentiating a logarithm value that was serialized back as text.","commonSituations":"Growth/decay calculations where an intermediate field lost its numeric type; values round-tripped through string fields in old Kettle transformations.","solutions":["Convert the Value to a numeric type before calling exp()","Ensure upstream steps keep the field typed as Number","Check isNumeric() and handle non-numeric values before the call"],"exampleFix":"// before\nValue result = value.exp(); // value is a String\n// after\nif (!value.isNumeric()) {\n  value.setType(Value.VALUE_TYPE_NUMBER);\n}\nValue result = value.exp();","handlingStrategy":"type-guard","validationCode":"if (value == null || !value.isNumeric()) {\n  throw new IllegalArgumentException(\"EXP requires a numeric value, got type \" + (value == null ? \"null\" : value.getType()));\n}","typeGuard":"boolean isNumericValue(Value v) { return v != null && v.isNumeric(); }","tryCatchPattern":"try {\n  result = value.exp();\n} catch (KettleValueException e) {\n  value.setType(Value.VALUE_TYPE_NUMBER);\n  result = value.exp();\n}","preventionTips":["Keep intermediate calculation results in numeric fields; avoid String round-trips","Convert values back to Number after any formatting step","Call isNumeric() before exponential functions","Preview row types when a transformation's output suddenly becomes String"],"tags":["kettle","numeric-type","math-function","runtime-type-check"],"backgroundTag":"type-mismatch","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"}