jd-opensource/joyagent-jdgenie · error · CatalogException

字段" + fieldName + "值\"" + value + "\"转换成数值失败

Error message

字段" + fieldName + "值\"" + value + "\"转换成数值失败

What it means

ClickhouseCatalog.parseDecimal converts a string column value to BigDecimal. If the value is non-blank but not a valid decimal number, it throws CatalogException '字段<fieldName>值"<value>"转换成数值失败'. This guards callers from silently receiving a null or malformed numeric value.

Solutions

  1. Validate the value is a valid decimal (regex ^-?\d+(\.\d+)?$) before calling parseDecimal.
  2. Clean the value: strip separators/symbols and trim whitespace.
  3. Change the source column to a numeric ClickHouse type so raw values are already numeric.
  4. Catch CatalogException and treat the row as invalid data in your ETL.

Example fix

// before
catalog.parseDecimal("1,234.56", "amount"); // throws
// after
String cleaned = "1,234.56".replace(",", "").trim();
BigDecimal v = catalog.parseDecimal(cleaned, "amount");
Defensive patterns

Strategy: validation

Validate before calling

// Java: pre-validate the value parses as a decimal
boolean isDecimal(String v) {
    if (v == null || v.isBlank()) return true; // parseDecimal returns null for blank
    return v.trim().matches("-?\\d+(\\.\\d+)?");
}

Try / catch

try {
    BigDecimal d = catalog.parseDecimal(value, fieldName);
} catch (CatalogException e) {
    log.warn("Non-numeric value for {}: {}", fieldName, value);
    // treat row as invalid or apply default
}

Prevention

When it happens

Trigger: Calling parseDecimal(value, fieldName) with a string like 'abc', '1.2.3', or a localized number with thousand separators that BigDecimal cannot parse.

Common situations: ClickHouse columns of type String/Enum that actually hold non-numeric data, values with spaces or currency symbols, or locale-formatted numbers (e.g. '1,234.56') coming from user input or CSV imports.

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 jd-opensource/joyagent-jdgenie@2417e0b8b6 (2026-09-08). Data as JSON: /api/errors/60e19b0bfdc9bd62. Report an issue: GitHub.

Appendix: source

Thrown at genie-backend/src/main/java/com/jd/genie/data/jdbc/catalog/clickhouse/ClickhouseCatalog.java:57

    }


    public String getColumnType(String columnType) {
        return switch (StandardColumnType.of(columnType)) {
            case DECIMAL -> "Decimal64(4)";
            case DATE -> "DateTime";
            default -> "String";
        };
    }


    public BigDecimal parseDecimal(String value, String fieldName) {
        BigDecimal decimal = null;
        if (StringUtils.isNotBlank(value)) {
            try {
                decimal = new BigDecimal(value);
            } catch (Exception e) {
                throw new CatalogException("字段" + fieldName + "值\"" + value + "\"转换成数值失败", e);
            }
        }
        return decimal;
    }
}

View on GitHub (pinned to 2417e0b8b6)