{"record":{"id":"823e05dd3551cce1","repo":"pentaho/pentaho-kettle","slug":"tostring-couldn-t-convert-string-value-string-to-a-big","errorCode":null,"errorMessage":"<toString()> : couldn't convert string value '<string>' to a big number.","messagePattern":"<toString\\(\\)> : couldn't convert string value '<string>' to a big number\\.","errorType":"exception","errorClass":"KettleValueException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java","lineNumber":1417,"sourceCode":"      }\n\n      // PDI-17366: Cannot simply cast a number to a BigDecimal,\n      //            If the Number is not a BigDecimal.\n      //\n      if ( number instanceof Double ) {\n        return BigDecimal.valueOf( number.doubleValue() );\n      } else if ( number instanceof Long ) {\n        return BigDecimal.valueOf( number.longValue() );\n      }\n      return (BigDecimal) number;\n\n    } catch ( Exception e ) {\n      // We added this workaround for PDI-1824\n      //\n      try {\n        return new BigDecimal( string );\n      } catch ( NumberFormatException ex ) {\n        throw new KettleValueException( toString() + \" : couldn't convert string value '\" + string\n            + \"' to a big number.\", ex );\n      }\n    }\n  }\n\n  // BOOLEAN + STRING\n\n  protected String convertBooleanToString( Boolean bool ) {\n    if ( bool == null ) {\n      return null;\n    }\n    if ( length >= 3 ) {\n      return bool.booleanValue() ? \"true\" : \"false\";\n    } else {\n      return bool.booleanValue() ? \"Y\" : \"N\";\n    }\n  }\n","sourceCodeStart":1399,"sourceCodeEnd":1435,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java#L1399-L1435","documentation":"Thrown by ValueMetaBase.convertStringToBigNumber after both the DecimalFormat parse and the fallback new BigDecimal(string) both fail with NumberFormatException. This is Kettle's last-resort error indicating the string simply is not a valid big-number literal.","triggerScenarios":"convertStringToBigNumber(String) with input like 'abc', '', '1.2.3', or numbers containing illegal characters that neither the configured format nor BigDecimal's constructor can parse.","commonSituations":"Bad CSV data (empty cells, headers repeated in data rows), decimal/thousands separator confusion, scientific notation exceeding mask expectations, or whitespace/nbsp characters inside the number.","solutions":["Fix or filter the offending source value; validate it matches a numeric regex before conversion.","Trim the string and remove grouping separators/BOM (setTrimType, setGroupingSymbol) so BigDecimal can parse it.","Use a 'Filter rows' or 'If field value is null/invalid' step to route bad rows to an error stream.","If the mask is wrong, correct setConversionMask so the first (DecimalFormat) parse succeeds."],"exampleFix":"// before: raw = \"1 234,56 EUR\" -> NumberFormatException\n// after: sanitize then convert\nString cleaned = raw.replace(\"EUR\", \"\").replace(\"\\u00A0\", \"\").trim();\nBigDecimal bd = new BigDecimal(cleaned.replace('.', ',').replace(',', '.')); // normalize separators","handlingStrategy":"validation","validationCode":"if (s == null || !s.trim().matches(\"[+-]?\\\\d*([.,]\\\\d+)?([Ee][+-]?\\\\d+)?\")) {\n    throw new IllegalArgumentException(\"Not a big number literal: \" + s);\n}","typeGuard":"static boolean isBigDecimal(String s) { try { new java.math.BigDecimal(s.trim()); return true; } catch (Exception e) { return false; } }","tryCatchPattern":"try {\n    BigDecimal bd = valueMeta.getBigNumber(s);\n} catch (KettleValueException e) {\n    log.error(\"Unparseable number '\" + s + \"' in field \" + valueMeta.getName());\n    bd = null; // or send to reject stream\n}","preventionTips":["Set trim type on input fields so stray whitespace never reaches BigDecimal","Normalize thousands/decimal separators before conversion","Use row filters/error streams to quarantine invalid numeric data early"],"tags":["pdi","bigdecimal","type-conversion","kettle"],"backgroundTag":"invalid-argument-format","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"}