apache/cassandra · error · IllegalArgumentException

There was a problem parsing the keyspace cql

Error message

There was a problem parsing the keyspace cql: %s

What it means

StressProfile.init validates the optional keyspace_definition CQL by parsing it with CqlParser::createKeyspaceStatement; a RecognitionException or SyntaxException is converted to IllegalArgumentException "There was a problem parsing the keyspace cql: <message>". This means the keyspace CQL in the stress profile is syntactically invalid or is not a CREATE KEYSPACE statement. A related assert also fails if the parsed keyspace name does not match the profile's keyspace property.

Solutions

  1. Read the embedded parse message to locate the syntax error and fix the CQL in keyspace_definition.
  2. Ensure the definition contains exactly one CREATE KEYSPACE statement whose name equals the profile's keyspace property.
  3. Check YAML block-scalar indentation so the whole CQL reaches the parser as one string.
  4. Test the CQL against the target Cassandra version's cqlsh to confirm it parses there.

Example fix

// before (profile YAML)
keyspace_definition: |
  CREATE KEYSPCE ks WITH replication = {'class': 'SimpleStrategy'};
// after
keyspace_definition: |
  CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
Defensive patterns

Strategy: validation

Validate before calling

String cql = profile.keyspaceDefinition; if (cql == null || !cql.trim().toUpperCase().startsWith("CREATE KEYSPACE")) throw new IllegalArgumentException("keyspace_definition must be a single CREATE KEYSPACE statement matching keyspace: " + profile.keyspace);

Try / catch

try { profile.init(stressSettings); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith("There was a problem parsing the keyspace cql")) System.err.println("Fix keyspace_definition in your stress profile YAML: " + e.getMessage()); throw e; }

Prevention

When it happens

Trigger: Providing a keyspace_definition in the stress profile whose CQL has syntax errors, uses grammar unsupported by the bundled parser version, or declares a different keyspace name than the profile's keyspace property (assertion path).

Common situations: Copy-pasted keyspace DDL with trailing statements or stray semicolons; using CQL features newer than the bundled ANTLR parser; mismatch between 'keyspace:' and the name in keyspace_definition; YAML indentation mangling the multi-line CQL string.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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

Appendix: source

Thrown at tools/stress/src/org/apache/cassandra/stress/StressProfile.java:217

        assert keyspaceName != null : "keyspace name is required in yaml file";
        assert tableName != null : "table name is required in yaml file";
        assert queries != null : "queries map is required in yaml file";

        for (String query : queries.keySet())
            assert !tokenRangeQueries.containsKey(query) :
                String.format("Found %s in both queries and token_range_queries, please use different names", query);

        if (keyspaceCql != null && keyspaceCql.length() > 0)
        {
            try
            {
                String name = CQLFragmentParser.parseAnyUnhandled(CqlParser::createKeyspaceStatement, keyspaceCql).keyspaceName;
                assert name.equalsIgnoreCase(keyspaceName) : "Name in keyspace_definition doesn't match keyspace property: '" + name + "' != '" + keyspaceName + "'";
            }
            catch (RecognitionException | SyntaxException e)
            {
                throw new IllegalArgumentException("There was a problem parsing the keyspace cql: " + e.getMessage());
            }
        }
        else
        {
            keyspaceCql = null;
        }

        if (tableCql != null && tableCql.length() > 0)
        {
            try
            {
                String name = CQLFragmentParser.parseAnyUnhandled(CqlParser::createTableStatement, tableCql).table();
                assert name.equalsIgnoreCase(tableName) : "Name in table_definition doesn't match table property: '" + name + "' != '" + tableName + "'";
            }
            catch (RecognitionException | RuntimeException e)
            {
                throw new IllegalArgumentException("There was a problem parsing the table cql: " + e.getMessage());
            }

View on GitHub (pinned to 88fd0f6a0e)