apache/cassandra · error · InvalidRequestException

Type ' . ' doesn't exist

Error message

Type '%s.%s' doesn't exist

What it means

Existence guard in DropTypeStatement.apply(): the user type named in DROP TYPE cannot be resolved — either the keyspace is missing or keyspace.types has no entry for typeName. Without IF EXISTS, the statement fails with InvalidRequestException identifying the nonexistent type.

Solutions

  1. Add IF EXISTS to tolerate an already-dropped type; confirm the type exists with DESCRIBE TYPE; check the keyspace qualification and spelling of the type name.

Example fix

// before
DROP TYPE ks.address;
// after
DROP TYPE IF EXISTS ks.address;
Defensive patterns

Strategy: validation

Validate before calling

var exists = session.execute("SELECT type_name FROM system_schema.types WHERE keyspace_name=? AND type_name=?", ks, type).iterator().hasNext();
if (exists) session.execute("DROP TYPE IF EXISTS " + ks + "." + type);

Try / catch

try { session.execute(ddl); } catch (InvalidRequest e) { if (e.getMessage().contains("doesn't exist")) log.info("Type already absent"); else throw e; }

Prevention

When it happens

Trigger: Executing DROP TYPE <ks>.<type> for a type name not present in keyspace.types; misspelling the type; re-running a script after the type was already dropped; running against the wrong keyspace (useKeyspace not set).

Common situations: Scripts run twice; typos; connecting to a cluster where the UDT was never created; case-sensitivity confusion with quoted identifiers.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/a80a46c8af2d1c78. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/cql3/statements/schema/DropTypeStatement.java:81

    // TODO: expand types into tuples in all dropped columns of all tables
    @Override
    public Keyspaces apply(ClusterMetadata metadata)
    {
        ByteBuffer name = bytes(typeName);

        Keyspaces schema = metadata.schema.getKeyspaces();
        KeyspaceMetadata keyspace = schema.getNullable(keyspaceName);

        UserType type = null == keyspace
                      ? null
                      : keyspace.types.getNullable(name);

        if (null == type)
        {
            if (ifExists)
                return schema;

            throw ire("Type '%s.%s' doesn't exist", keyspaceName, typeName);
        }

        /*
         * We don't want to drop a type unless it's not used anymore (mainly because
         * if someone drops a type and recreates one with the same name but different
         * definition with the previous name still in use, things can get messy).
         * We have three places to check:
         * 1) UDFs and UDAs using the type
         * 2) other user type that can nest the one we drop and
         * 3) existing tables referencing the type (maybe in a nested way).
         */
        Iterable<UserFunction> functions = keyspace.userFunctions.referencingUserType(name);
        if (!isEmpty(functions))
        {
            throw ire("Cannot drop user type '%s.%s' as it is still used by functions %s",
                      keyspaceName,
                      typeName,
                      join(", ", transform(functions, f -> f.name().toString())));

View on GitHub (pinned to 88fd0f6a0e)