apache/cassandra · error · InvalidRequestException

Keyspace ' ' doesn't exist

Error message

Keyspace '%s' doesn't exist

What it means

Dependency check in CreateViewStatement.apply() during schema mutation: the keyspace the materialized view is to be created in (keyspaceName) is not present in the current cluster metadata. Since a view cannot exist without its parent keyspace, the coordinator rejects the change with InvalidRequestException naming the missing keyspace.

Solutions

  1. Create the keyspace first (CREATE KEYSPACE) then retry the CREATE MATERIALIZED VIEW; verify the keyspace name spelling and case; USE the correct keyspace or fully qualify the view name if the statement resolved to the wrong keyspace.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/java/org/apache/cassandra/cql3/statements/schema/CreateViewStatement.java:148 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at src/java/org/apache/cassandra/cql3/statements/schema/CreateViewStatement.java:148

        this.state = state;
    }

    @Override
    public boolean compatibleWith(ClusterMetadata metadata)
    {
        return metadata.directory.commonSerializationVersion.isAtLeast(Version.V0);
    }

    @Override
    public Keyspaces apply(ClusterMetadata metadata)
    {
        /*
         * Basic dependency validations
         */
        Keyspaces schema = metadata.schema.getKeyspaces();
        KeyspaceMetadata keyspace = schema.getNullable(keyspaceName);
        if (null == keyspace)
            throw ire("Keyspace '%s' doesn't exist", keyspaceName);

        if (keyspace.replicationStrategy.hasTransientReplicas())
            throw new InvalidRequestException("Materialized views are not supported on transiently replicated keyspaces");

        TableMetadata table = keyspace.tables.getNullable(tableName);
        if (null == table)
            throw ire("Base table '%s' doesn't exist", tableName);

        if (keyspace.hasTable(viewName))
            throw ire("Cannot create materialized view '%s' - a table with the same name already exists", viewName);

        if (keyspace.hasView(viewName))
        {
            if (ifNotExists)
                return schema;

            throw new AlreadyExistsException(keyspaceName, viewName);
        }

View on GitHub (pinned to 88fd0f6a0e)