{"record":{"id":"e9a0b5a249c24d53","repo":"OtterMind/Chat2DB","slug":"invalid-hive-default-value-value","errorCode":null,"errorMessage":"Invalid Hive default value: {value}","messagePattern":"Invalid Hive default value: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"chat2db-community-server/chat2db-community-plugins/chat2db-community-hive/src/main/java/ai/chat2db/plugin/hive/HiveSqlGuards.java","lineNumber":52,"sourceCode":"\n    /**\n     * Validate a strict Hive name token (ENGINE / CHARACTER SET / COLLATE style positions where\n     * escaping is impossible by design).\n     */\n    public static String requireHiveName(String value, String what) {\n        if (value == null || !HIVE_NAME_PATTERN.matcher(value).matches()) {\n            throw new IllegalArgumentException(\"Invalid Hive \" + what + \": \" + value);\n        }\n        return value;\n    }\n\n    /**\n     * Validate a raw DEFAULT literal for numeric-ish columns (positions where quoting would change\n     * semantics). Accepts decimal/scientific numbers, hex literals, TRUE/FALSE.\n     */\n    public static String requireNumericDefault(String value) {\n        if (value == null || !NUMERIC_DEFAULT_PATTERN.matcher(value.trim()).matches()) {\n            throw new IllegalArgumentException(\"Invalid Hive default value: \" + value);\n        }\n        return value;\n    }\n\n    /**\n     * Validate a Hive type expression, including nested ARRAY, MAP, STRUCT, and UNIONTYPE forms.\n     */\n    public static String requireColumnTypeExpression(String value) {\n        if (StringUtils.isBlank(value)) {\n            throw invalid(\"column type\", value);\n        }\n        String expression = value.trim();\n        scanTypeExpression(expression, \"column type\", false);\n        return expression;\n    }\n\n    /**\n     * Validate the raw table partition tail accepted by the legacy builder.","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/OtterMind/Chat2DB/blob/5ee1e990e73fbcae1969dc554be254fedb3ab888/chat2db-community-server/chat2db-community-plugins/chat2db-community-hive/src/main/java/ai/chat2db/plugin/hive/HiveSqlGuards.java#L34-L70","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Provide a plain numeric literal (\"0\", \"3.14\", \"1e5\") or TRUE/FALSE for numeric columns.","If the column should default to a string, change the column type to STRING and use the quoted-default path instead of requireNumericDefault.","Leave the default blank when none is intended."],"exampleFix":"// before\ncolumn.setDefaultValue(\"'0'\"); // quotes break numeric pattern\nHiveSqlGuards.requireNumericDefault(column.getDefaultValue());\n\n// after\ncolumn.setDefaultValue(\"0\"); // bare numeric literal\nHiveSqlGuards.requireNumericDefault(column.getDefaultValue());","handlingStrategy":"validation","validationCode":"private static final java.util.regex.Pattern NUMERIC_DEFAULT =\n    java.util.regex.Pattern.compile(\"^[+-]?(?:\\\\d+(?:\\\\.\\\\d*)?|\\\\.\\\\d+)(?:[eE][+-]?\\\\d+)?$|\" +\n        \"(?i)^0x[0-9a-f]+$|^(?:TRUE|FALSE)$\");\nstatic boolean isHiveNumericDefault(String v) {\n    return v != null && NUMERIC_DEFAULT.matcher(v.trim()).matches();\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Provide a bare numeric/hex/boolean literal for numeric Hive column defaults.","If a string default is needed, switch the column to a string type and use the quoted path.","Strip accidental quotes from numeric defaults at import time."],"tags":["hive","sql-guard","ddl","default","validation"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}