OtterMind/Chat2DB · error · IllegalArgumentException

Unsupported Snowflake index type: {indexType}

Error message

Unsupported Snowflake index type: {indexType}

What it means

Thrown by SnowflakeSqlBuilder.requireIndexType during CREATE TABLE generation when an index's type string does not match any SnowflakeIndexTypeEnum name. The match is case-insensitive against the enum 'name' field, whose only legal values are 'Primary', 'Normal', 'Unique', 'Fulltext', and 'Spatial'. A blank name or blank type is silently skipped (line 120-122), but a non-blank unrecognized type fails hard.

Source

Thrown at chat2db-community-server/chat2db-community-plugins/chat2db-community-snowflake/src/main/java/ai/chat2db/plugin/snowflake/builder/SnowflakeSqlBuilder.java:207

            script = new StringBuilder(script.substring(0, script.length() - 2));
            script.append(SQLConstants.SEMICOLON);
        }

        return script.toString();
    }

    private SnowflakeColumnTypeEnum requireColumnType(String columnType) {
        SnowflakeColumnTypeEnum typeEnum = SnowflakeColumnTypeEnum.getByType(columnType);
        if (typeEnum == null) {
            throw new IllegalArgumentException("Unsupported Snowflake column type: " + columnType);
        }
        return typeEnum;
    }

    private SnowflakeIndexTypeEnum requireIndexType(String indexType) {
        SnowflakeIndexTypeEnum typeEnum = SnowflakeIndexTypeEnum.getByType(indexType);
        if (typeEnum == null) {
            throw new IllegalArgumentException("Unsupported Snowflake index type: " + indexType);
        }
        return typeEnum;
    }

}

View on GitHub (pinned to 5ee1e990e7)

Solutions

  1. Set the index type to one of the canonical names: 'Primary', 'Normal', 'Unique', 'Fulltext', or 'Spatial'.
  2. Map/crosswalk index types from the source dialect before populating the Snowflake TableIndex.
  3. Leave both name and type blank to have the index skipped rather than throw.

Example fix

// before
idx.setType("BTREE"); // -> Unsupported Snowflake index type

// after
idx.setType("Normal");
Defensive patterns

Strategy: validation

Validate before calling

// Validate index type against the canonical names before buildCreateTable
static final Set<String> OK = Set.of("Primary", "Normal", "Unique", "Fulltext", "Spatial");
for (TableIndex idx : table.getIndexList()) {
    if (StringUtils.isNotBlank(idx.getType())
            && OK.stream().noneMatch(n -> n.equalsIgnoreCase(idx.getType()))) {
        throw new IllegalArgumentException("Bad index type: " + idx.getType());
    }
}

Type guard

static boolean isSupportedSnowflakeIndexType(String type) {
    return type != null && SnowflakeIndexTypeEnum.getByType(type) != null;
}

Prevention

When it happens

Trigger: Calling buildCreateTable with a TableIndex whose getType() is non-blank yet not one of Primary/Normal/Unique/Fulltext/Spatial (e.g. 'BTREE', 'HASH', 'CLUSTERED', or a lowercase 'primary').

Common situations: Copying index metadata from another dialect (MySQL 'BTREE', SQL Server 'CLUSTERED') into the Snowflake model; locale/casing differences; a UI dropdown emitting a label instead of the canonical enum name.

Related errors


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