OtterMind/Chat2DB · error · IllegalArgumentException

Invalid Hive default value: {value}

Error message

Invalid Hive default value: {value}

What it means

Thrown by HiveSqlGuards.requireNumericDefault when a raw DEFAULT literal for a numeric-ish Hive column does not match NUMERIC_DEFAULT_PATTERN (decimal/scientific numbers, hex literals, TRUE/FALSE). Quoting such a default would change its semantics, so the guard rejects anything that is not a valid bare numeric/boolean literal.

Source

Thrown at chat2db-community-server/chat2db-community-plugins/chat2db-community-hive/src/main/java/ai/chat2db/plugin/hive/HiveSqlGuards.java:52

    /**
     * Validate a strict Hive name token (ENGINE / CHARACTER SET / COLLATE style positions where
     * escaping is impossible by design).
     */
    public static String requireHiveName(String value, String what) {
        if (value == null || !HIVE_NAME_PATTERN.matcher(value).matches()) {
            throw new IllegalArgumentException("Invalid Hive " + what + ": " + value);
        }
        return value;
    }

    /**
     * Validate a raw DEFAULT literal for numeric-ish columns (positions where quoting would change
     * semantics). Accepts decimal/scientific numbers, hex literals, TRUE/FALSE.
     */
    public static String requireNumericDefault(String value) {
        if (value == null || !NUMERIC_DEFAULT_PATTERN.matcher(value.trim()).matches()) {
            throw new IllegalArgumentException("Invalid Hive default value: " + value);
        }
        return value;
    }

    /**
     * Validate a Hive type expression, including nested ARRAY, MAP, STRUCT, and UNIONTYPE forms.
     */
    public static String requireColumnTypeExpression(String value) {
        if (StringUtils.isBlank(value)) {
            throw invalid("column type", value);
        }
        String expression = value.trim();
        scanTypeExpression(expression, "column type", false);
        return expression;
    }

    /**
     * Validate the raw table partition tail accepted by the legacy builder.

View on GitHub (pinned to 5ee1e990e7)

Solutions

  1. Provide a plain numeric literal ("0", "3.14", "1e5") or TRUE/FALSE for numeric columns.
  2. If the column should default to a string, change the column type to STRING and use the quoted-default path instead of requireNumericDefault.
  3. Leave the default blank when none is intended.

Example fix

// before
column.setDefaultValue("'0'"); // quotes break numeric pattern
HiveSqlGuards.requireNumericDefault(column.getDefaultValue());

// after
column.setDefaultValue("0"); // bare numeric literal
HiveSqlGuards.requireNumericDefault(column.getDefaultValue());
Defensive patterns

Strategy: validation

Validate before calling

private static final java.util.regex.Pattern NUMERIC_DEFAULT =
    java.util.regex.Pattern.compile("^[+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:[eE][+-]?\\d+)?$|" +
        "(?i)^0x[0-9a-f]+$|^(?:TRUE|FALSE)$");
static boolean isHiveNumericDefault(String v) {
    return v != null && NUMERIC_DEFAULT.matcher(v.trim()).matches();
}

Prevention

When it happens

Trigger: Calling requireNumericDefault(value) where value is a non-numeric expression, a quoted string, a function call, or null. Reached when building Hive column DDL for a numeric column whose default is in a non-escapable position.

Common situations: A numeric column given a string default by mistake; a default expression like "1+1" or a function; importing a schema whose numeric default was stored with quotes.

Related errors


AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14). Data as JSON: /api/errors/e9a0b5a249c24d53. Report an issue: GitHub.