OtterMind/Chat2DB · error · IllegalArgumentException
Hive index requires at least one named column
Error message
Hive index requires at least one named column
What it means
Thrown in HiveIndexTypeEnum.buildIndexColumn when tableIndex.getColumnList() is null. The builder cannot construct an index with no column list at all, so it fails fast rather than producing malformed SQL.
Source
Thrown at chat2db-community-server/chat2db-community-plugins/chat2db-community-hive/src/main/java/ai/chat2db/plugin/hive/enums/type/HiveIndexTypeEnum.java:98
return script.toString();
}
private String buildIndexComment(TableIndex tableIndex) {
if(StringUtils.isBlank(tableIndex.getComment())){
return "";
}else {
return StringUtils.join(SQL_COMMENT, HiveIdentifierProcessor.INSTANCE.escapeString(tableIndex.getComment()),"'");
}
}
private String buildIndexColumn(TableIndex tableIndex) {
StringBuilder script = new StringBuilder();
script.append("(");
boolean appended = false;
if (tableIndex.getColumnList() == null) {
throw new IllegalArgumentException("Hive index requires at least one named column");
}
for (TableIndexColumn column : tableIndex.getColumnList()) {
if(StringUtils.isNotBlank(column.getColumnName())) {
script.append(HiveIdentifierProcessor.INSTANCE.quoteIdentifierAlways(column.getColumnName()));
if (!StringUtils.isBlank(column.getAscOrDesc()) && !PRIMARY_KEY.equals(this)) {
script.append(" ").append(HiveSqlGuards.requireAscOrDesc(column.getAscOrDesc()));
}
script.append(",");
appended = true;
}
}
if (!appended) {
throw new IllegalArgumentException("Hive index requires at least one named column");
}
script.deleteCharAt(script.length() - 1);
script.append(")");
return script.toString();
}View on GitHub (pinned to 5ee1e990e7)
Solutions
- Always initialize TableIndex.columnList (even to an empty list) before building Hive index DDL.
- Guard callers: skip indexes whose columnList is null.
- In the model factory, default columnList to Collections.emptyList().
Example fix
// before TableIndex idx = new TableIndex(); idx.setColumnList(null); hiveIndexTypeEnum.buildIndexScript(idx); // after TableIndex idx = new TableIndex(); idx.setColumnList(new ArrayList<>()); // non-null, then ensure at least one named column idx.getColumnList().add(namedColumn);
Defensive patterns
Strategy: validation
Validate before calling
static boolean hasColumnList(TableIndex idx) {
return idx != null && idx.getColumnList() != null;
} Prevention
- Always initialize TableIndex.columnList (even to an empty list).
- Skip indexes with null columnList at the caller boundary.
- Default columnList to Collections.emptyList() in the model factory.
When it happens
Trigger: Calling buildIndexScript/buildModifyIndex on a Hive TableIndex whose columnList was never set (null). Common when constructing an index object programmatically without initializing its columns.
Common situations: A new TableIndex created via constructor/default with no setColumnList(...); deserialization producing a null columnList; copying an index shell for templating.
Related errors
- Invalid Hive index sort direction: {value}
- Unsupported Hive index type: {type}
- Invalid DB2 index column ordering: {ascOrDesc}
- Invalid DM index sort direction: {value}
- DM index must contain at least one named column
AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14).
Data as JSON: /api/errors/46009f16580caa84.
Report an issue: GitHub.