pentaho/pentaho-kettle · error · KettleValueException

<toString()> : couldn't convert string value

Error message

<toString()> : couldn't convert string value '<string>' to a big number.

What it means

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.

Solutions

  1. Fix or filter the offending source value; validate it matches a numeric regex before conversion.
  2. Trim the string and remove grouping separators/BOM (setTrimType, setGroupingSymbol) so BigDecimal can parse it.
  3. Use a 'Filter rows' or 'If field value is null/invalid' step to route bad rows to an error stream.
  4. If the mask is wrong, correct setConversionMask so the first (DecimalFormat) parse succeeds.

Example fix

// before: raw = "1 234,56 EUR" -> NumberFormatException
// after: sanitize then convert
String cleaned = raw.replace("EUR", "").replace("\u00A0", "").trim();
BigDecimal bd = new BigDecimal(cleaned.replace('.', ',').replace(',', '.')); // normalize separators
Defensive patterns

Strategy: validation

Validate before calling

if (s == null || !s.trim().matches("[+-]?\\d*([.,]\\d+)?([Ee][+-]?\\d+)?")) {
    throw new IllegalArgumentException("Not a big number literal: " + s);
}

Type guard

static boolean isBigDecimal(String s) { try { new java.math.BigDecimal(s.trim()); return true; } catch (Exception e) { return false; } }

Try / catch

try {
    BigDecimal bd = valueMeta.getBigNumber(s);
} catch (KettleValueException e) {
    log.error("Unparseable number '" + s + "' in field " + valueMeta.getName());
    bd = null; // or send to reject stream
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/823e05dd3551cce1. Report an issue: GitHub.

Appendix: source

Thrown at core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java:1417

      }

      // PDI-17366: Cannot simply cast a number to a BigDecimal,
      //            If the Number is not a BigDecimal.
      //
      if ( number instanceof Double ) {
        return BigDecimal.valueOf( number.doubleValue() );
      } else if ( number instanceof Long ) {
        return BigDecimal.valueOf( number.longValue() );
      }
      return (BigDecimal) number;

    } catch ( Exception e ) {
      // We added this workaround for PDI-1824
      //
      try {
        return new BigDecimal( string );
      } catch ( NumberFormatException ex ) {
        throw new KettleValueException( toString() + " : couldn't convert string value '" + string
            + "' to a big number.", ex );
      }
    }
  }

  // BOOLEAN + STRING

  protected String convertBooleanToString( Boolean bool ) {
    if ( bool == null ) {
      return null;
    }
    if ( length >= 3 ) {
      return bool.booleanValue() ? "true" : "false";
    } else {
      return bool.booleanValue() ? "Y" : "N";
    }
  }

View on GitHub (pinned to f3058517a1)