{"record":{"id":"896f6eb4e38bc746","repo":"pentaho/pentaho-kettle","slug":"function-atan-only-works-with-numeric-data","errorCode":null,"errorMessage":"Function ATAN only works with numeric data","messagePattern":"Function ATAN only works with numeric data","errorType":"exception","errorClass":"KettleValueException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/compatibility/Value.java","lineNumber":2410,"sourceCode":"\n    if ( isNumeric() ) {\n      setValue( Math.asin( getNumber() ) );\n    } else {\n      throw new KettleValueException( \"Function ASIN only works with numeric data\" );\n    }\n    return this;\n  }\n\n  // implement the ATAN function, arguments in args[]\n  public Value atan() throws KettleValueException {\n    if ( isNull() ) {\n      return this;\n    }\n\n    if ( isNumeric() ) {\n      setValue( Math.atan( getNumber() ) );\n    } else {\n      throw new KettleValueException( \"Function ATAN only works with numeric data\" );\n    }\n    return this;\n  }\n\n  // implement the ATAN2 function, arguments in args[]\n  public Value atan2( Value arg0 ) throws KettleValueException {\n    return atan2( arg0.getNumber() );\n  }\n\n  public Value atan2( double arg0 ) throws KettleValueException {\n    if ( isNull() ) {\n      return this;\n    }\n\n    if ( isNumeric() ) {\n      setValue( Math.atan2( getNumber(), arg0 ) );\n    } else {\n      throw new KettleValueException( \"Function ATAN2 only works with numbers\" );","sourceCodeStart":2392,"sourceCodeEnd":2428,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/compatibility/Value.java#L2392-L2428","documentation":"The atan() method of Kettle's legacy Value class computes the arc tangent of the value. It requires a numeric Value; if isNumeric() returns false it throws this KettleValueException because Math.atan needs a double. The legacy Value API checks types at runtime rather than at compile time.","triggerScenarios":"Calling Value.atan() on a Value typed as String, Date, Boolean or other non-numeric type - commonly a raw text field passed directly into the trigonometric function.","commonSituations":"Calculations in Formula/JavaScript steps on fields from delimited-file inputs typed as String; missing 'Select values' type conversion between input and calculation steps.","solutions":["Convert the Value to Number before calling atan() (setType(VALUE_TYPE_NUMBER) or conversion in the stream)","Ensure the source step produces a Number-typed field","Check isNumeric() before the call and branch accordingly"],"exampleFix":"// before\nValue result = value.atan();\n// after\nif (!value.isNumeric()) {\n  value.setType(Value.VALUE_TYPE_NUMBER);\n}\nValue result = value.atan();","handlingStrategy":"type-guard","validationCode":"if (value == null || !value.isNumeric()) {\n  throw new IllegalArgumentException(\"ATAN 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.atan();\n} catch (KettleValueException e) {\n  value.setType(Value.VALUE_TYPE_NUMBER);\n  result = value.atan();\n}","preventionTips":["Declare angle/ratio columns as numeric in the input step metadata","Use a Select values step to convert String fields to Number before calculations","Precondition-check with isNumeric() before trigonometric calls","Keep type-conversion steps adjacent to calculation steps in the transformation"],"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"}