{"record":{"id":"3f3681d6588af4b3","repo":"pentaho/pentaho-kettle","slug":"function-str2num-works-only-on-strings","errorCode":null,"errorMessage":"Function STR2NUM works only on strings","messagePattern":"Function STR2NUM works only on strings","errorType":"exception","errorClass":"KettleValueException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/compatibility/Value.java","lineNumber":3242,"sourceCode":"          } catch ( Exception e ) {\n            String message = \"Couldn't convert string to number \" + e.toString();\n            if ( !Utils.isEmpty( pattern ) ) {\n              message += \" pattern=\" + pattern;\n            }\n            if ( !Utils.isEmpty( decimal ) ) {\n              message += \" decimal=\" + decimal;\n            }\n            if ( !Utils.isEmpty( grouping ) ) {\n              message += \" grouping=\" + grouping.charAt( 0 );\n            }\n            if ( !Utils.isEmpty( currency ) ) {\n              message += \" currency=\" + currency;\n            }\n            throw new KettleValueException( message );\n          }\n        }\n      } else {\n        throw new KettleValueException( \"Function STR2NUM works only on strings\" );\n      }\n    }\n    return this;\n  }\n\n  public Value dat2num() throws KettleValueException {\n    if ( isNull() ) {\n      setType( VALUE_TYPE_INTEGER );\n      return this;\n    }\n\n    if ( getType() == VALUE_TYPE_DATE ) {\n      if ( getString() == null ) {\n        setNull();\n        setValue( 0L );\n      } else {\n        setValue( getInteger() );\n      }","sourceCodeStart":3224,"sourceCodeEnd":3260,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/compatibility/Value.java#L3224-L3260","documentation":"Guard at the top of the legacy Value str2num() function: the value being converted is not of String type, so the string-to-number parser refuses to run. The input at fault is the current Value whose type is not VALUE_TYPE_STRING.","triggerScenarios":"Thrown at core/src/main/java/org/pentaho/di/compatibility/Value.java:3242 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the field passed to STR2NUM is a String","Convert the value to String first if it originates from another type"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}