OtterMind/Chat2DB · error · IllegalArgumentException
Invalid Hive {what}: {value}
Error message
Invalid Hive {what}: {value} What it means
Thrown by HiveSqlGuards.requireHiveName when a name (engine, character set, collate, etc.) fails the HIVE_NAME_PATTERN allow-list. Hive exposes these as bare, non-escapable tokens in DDL, so they are restricted to a safe character set rather than escaped. Null or any non-matching value is rejected.
Source
Thrown at chat2db-community-server/chat2db-community-plugins/chat2db-community-hive/src/main/java/ai/chat2db/plugin/hive/HiveSqlGuards.java:41
"^([+-]?(\\d+(\\.\\d+)?|\\.\\d+)([eE][+-]?\\d+)?|0[xX][0-9a-fA-F]+|(?i:TRUE|FALSE))$");
private static final Set<String> TYPE_BREAKOUT_KEYWORDS = Set.of(
"ALTER", "CHECK", "CONSTRAINT", "CREATE", "DEFAULT", "DELETE", "DROP", "GENERATED",
"GRANT", "INSERT", "NOT", "NULL", "PRIMARY", "REFERENCES", "REVOKE", "TRUNCATE",
"UNIQUE", "UPDATE");
private static final Set<String> MULTI_WORD_TYPES = Set.of(
"CHARACTER VARYING", "DOUBLE PRECISION", "TIME WITH LOCAL TIME ZONE", "TIME WITH TIME ZONE",
"TIMESTAMP WITH LOCAL TIME ZONE", "TIMESTAMP WITH TIME ZONE");
private HiveSqlGuards() {
}
/**
* 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.
*/View on GitHub (pinned to 5ee1e990e7)
Solutions
- Use a plain Hive-legal name (letters/digits/underscore) for engine/charset/collate fields.
- If the value is user-entered, validate it against HIVE_NAME_PATTERN before building the DDL.
- Leave the field blank when it is not required rather than passing a placeholder.
Example fix
// before
table.setEngine("org.apache.hadoop.hive.ql.io.OrcInputFormat"); // dots/spaces fail
HiveSqlGuards.requireHiveName(table.getEngine(), "engine");
// after
table.setEngine("orc"); // bare Hive engine/storage token
HiveSqlGuards.requireHiveName(table.getEngine(), "engine"); Defensive patterns
Strategy: validation
Validate before calling
// HIVE_NAME_PATTERN is not public; mirror its intent with an equivalent check
private static final java.util.regex.Pattern HIVE_NAME =
java.util.regex.Pattern.compile("^[A-Za-z_][A-Za-z0-9_]*$");
static boolean isSafeHiveName(String v) {
return v != null && HIVE_NAME.matcher(v).matches();
} Type guard
static String hiveNameOrNull(String v) {
return (v != null && HIVE_NAME.matcher(v).matches()) ? v : null;
} Prevention
- Use bare Hive-legal tokens for engine/charset/collate fields.
- Leave those fields blank when not required.
- Validate user-entered Hive names client-side before DDL generation.
When it happens
Trigger: Calling requireHiveName(value, what) for table.getEngine(), a character set, or a collation whose value contains characters outside the allowed Hive name pattern. Reached from HiveSqlBuilder when building CREATE TABLE ... ENGINE .../CHARACTER SET/COLLATE clauses.
Common situations: A Hive engine/serde name with a hyphen, space, or path separator; a collation copied from another DB; a manually typed engine name in the table form.
Related errors
- Invalid Hive default value: {value}
- Invalid Hive index sort direction: {value}
- Invalid DB2 index column ordering: {ascOrDesc}
- Unsupported DM VARCHAR unit: {unit}
- Invalid DM index sort direction: {value}
AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14).
Data as JSON: /api/errors/74c962f19ab88b17.
Report an issue: GitHub.