apache/cassandra · error · java.lang.IllegalStateException

No modification (INSERT/UPDATE/DELETE) statement specified,

Error message

No modification (INSERT/UPDATE/DELETE) statement specified, you should provide a modification statement through using()

What it means

Thrown by CQLSSTableWriter.Builder.build() as an IllegalStateException when no modification statement (INSERT/UPDATE/DELETE via using()) was configured. The writer serializes each added row by executing this prepared modification statement, so it cannot operate without one.

Source

Thrown at src/java/org/apache/cassandra/io/sstable/CQLSSTableWriter.java:700

         * Use specific compression dictionary upon writing the data.
         *
         * @param compressionDictionary compression dictionary to use
         * @return this builder
         */
        public Builder withCompressionDictionary(CompressionDictionary compressionDictionary)
        {
            this.compressionDictionary = compressionDictionary;
            return this;
        }

        public CQLSSTableWriter build()
        {
            if (directory == null)
                throw new IllegalStateException("No ouptut directory specified, you should provide a directory with inDirectory()");
            if (schemaStatement == null)
                throw new IllegalStateException("Missing schema, you should provide the schema for the SSTable to create with forTable()");
            if (modificationStatement == null)
                throw new IllegalStateException("No modification (INSERT/UPDATE/DELETE) statement specified, you should provide a modification statement through using()");

            Set<String> activeKeyspaces = new HashSet<>(SchemaConstants.LOCAL_SYSTEM_KEYSPACE_NAMES);

            if (!DatabaseDescriptor.getAccordTransactionsEnabled())
                activeKeyspaces.remove(SchemaConstants.ACCORD_KEYSPACE_NAME);

            Preconditions.checkState(Sets.difference(activeKeyspaces, Schema.instance.getKeyspaces()).isEmpty(),
                                     "Local keyspaces were not loaded. If this is running as a client, please make sure to add %s=true system property.",
                                     CassandraRelevantProperties.FORCE_LOAD_LOCAL_KEYSPACES.getKey());

            // Assign the default max SSTable size if not defined in builder
            if (isMaxSSTableSizeUnset())
            {
                maxSSTableSizeInMiB = sorted ? -1L : DEFAULT_BUFFER_SIZE_IN_MIB_FOR_UNSORTED;
            }

            synchronized (CQLSSTableWriter.class)
            {

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Add .using("INSERT INTO ks.tbl (k, v) VALUES (?, ?)") before build()
  2. Fix any CQL syntax error in the statement passed to using() that caused setup to be skipped
  3. Verify the statement's bound variables align with the schema and your row values

Example fix

// before
CQLSSTableWriter writer = CQLSSTableWriter.builder()
    .inDirectory(dir).forTable(schema).build();
// after
CQLSSTableWriter writer = CQLSSTableWriter.builder()
    .inDirectory(dir).forTable(schema)
    .using("INSERT INTO ks.tbl (k, v) VALUES (?, ?)").build();
Defensive patterns

Strategy: validation

Validate before calling

if (insertCql == null || insertCql.isEmpty()) throw new IllegalStateException("using() modification statement required before build()");

Type guard

null

Try / catch

try { writer = builder.build(); } catch (IllegalStateException e) { if (e.getMessage().contains("modification")) { /* supply using() and rebuild */ } throw e; }

Prevention

When it happens

Trigger: Calling build() without invoking using(...) on the Builder.

Common situations: Builders configured for reading-only workflows mistakenly; the using() call wrapped in a try/catch for CQL syntax errors that swallowed a failed assignment and left the field null; refactoring that renamed the insert statement variable without updating the builder chain.

Understand the failure class

Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.

Related errors


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