{"record":{"id":"cf6427397e5eec9b","repo":"pentaho/pentaho-kettle","slug":"function-asin-only-works-with-numeric-data","errorCode":null,"errorMessage":"Function ASIN only works with numeric data","messagePattern":"Function ASIN 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":2396,"sourceCode":"\n    if ( isNumeric() ) {\n      setValue( Math.acos( getNumber() ) );\n    } else {\n      throw new KettleValueException( \"Function ACOS only works with numeric data\" );\n    }\n    return this;\n  }\n\n  // implement the ASIN function, arguments in args[]\n  public Value asin() throws KettleValueException {\n    if ( isNull() ) {\n      return this;\n    }\n\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","sourceCodeStart":2378,"sourceCodeEnd":2414,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/compatibility/Value.java#L2378-L2414","documentation":"The asin() method of Kettle's legacy Value class computes the arc sine of the value. It checks isNumeric() first and throws this KettleValueException when the Value holds a non-numeric type, since Math.asin requires a double argument. This is a runtime type contract enforced by the legacy compatibility Value class.","triggerScenarios":"Calling Value.asin() when the Value type is String, Date, Boolean, etc. - typically a field that was never converted to Number after being read as text.","commonSituations":"Text-file or spreadsheet inputs producing String-typed columns; formula calculations chained on untyped fields; old transformations copied between environments where the input metadata differs.","solutions":["Convert the Value to a numeric type (setType(VALUE_TYPE_NUMBER) or the step's field-conversion mechanism) before calling asin()","Correct the upstream input step so the field is declared/read as Number","Wrap the call in an isNumeric() check and convert or skip non-numeric rows"],"exampleFix":"// before\nValue result = value.asin();\n// after\nif (!value.isNumeric()) {\n  value.setType(Value.VALUE_TYPE_NUMBER);\n}\nValue result = value.asin();","handlingStrategy":"type-guard","validationCode":"if (value == null || !value.isNumeric()) {\n  throw new IllegalArgumentException(\"ASIN 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.asin();\n} catch (KettleValueException e) {\n  value.setType(Value.VALUE_TYPE_NUMBER);\n  result = value.asin();\n}","preventionTips":["Ensure source steps produce Number-typed fields for trigonometric input","Convert field types explicitly in the stream rather than relying on defaults","Check isNumeric() before calling any legacy Value math method","Review transformation metadata after copying between environments"],"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"}