apache/cassandra · error · IllegalStateException
No insert statement specified, you should provide an insert…
Error message
No insert statement specified, you should provide an insert statement through using()
What it means
StressCQLSSTableWriter.Builder.build() requires an INSERT statement with bind variables, supplied via using(insertStatement). It throws IllegalStateException when none was set, since the writer has no statement to execute per row.
Solutions
- Add .using("INSERT INTO ks.tbl (...) VALUES (?, ?)") to the builder chain.
- Ensure the insert string is non-null and non-empty when assembled dynamically.
- Use '?' bind variables in the INSERT so rawAddRow can bind values.
- Order the builder calls readably: inDirectory, forTable, using, build.
Example fix
// before
builder.forTable(schema).build();
// after
builder.forTable(schema)
.using("INSERT INTO ks.tbl (k, v) VALUES (?, ?)")
.build(); Defensive patterns
Strategy: validation
Validate before calling
if (insertStmt == null || insertStmt.isBlank()) throw new IllegalStateException("using() required before build()");
builder.using(insertStmt); Try / catch
try { writer = builder.build(); }
catch (IllegalStateException e) { throw new IllegalStateException("supply insert via using(): " + e.getMessage(), e); } Prevention
- Build the writer through one factory method containing all required calls.
- Keep insert statements parameterized and validated.
- Check for empty strings when assembling CQL dynamically.
- Use a builder-usage lint/test in CI.
When it happens
Trigger: Calling build() without ever invoking using(...) on the Builder.
Common situations: Omitting the INSERT when copying builder examples; programmatic builder assembly where the insert string is built dynamically and ends up empty/unset; wrong builder method used (e.g. only forTable).
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- No output directories specified, you should provide a…
- Invalid number of arguments, expecting
- Invalid number of arguments, expecting
- Key in . is invalid in
- Missing schema, you should provide the schema for the…
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/03fc3c509c81865f.
Report an issue: GitHub.
Appendix: source
Thrown at tools/stress/src/org/apache/cassandra/io/sstable/StressCQLSSTableWriter.java:581
* <p>
* Note that if used, some option like withBufferSizeInMiB will be ignored.
*
* @return this builder.
*/
public Builder sorted()
{
this.sorted = true;
return this;
}
public StressCQLSSTableWriter build()
{
if (directoryList.isEmpty() && cfs == null)
throw new IllegalStateException("No output directories specified, you should provide a directory with inDirectory()");
if (schemaStatement == null && cfs == null)
throw new IllegalStateException("Missing schema, you should provide the schema for the SSTable to create with forTable()");
if (insertStatement == null)
throw new IllegalStateException("No insert statement specified, you should provide an insert statement through using()");
synchronized (StressCQLSSTableWriter.class)
{
if (cfs == null)
cfs = createOfflineTable(schemaStatement, typeStatements, directoryList);
if (partitioner == null)
partitioner = cfs.getPartitioner();
UpdateStatement preparedInsert = prepareInsert();
AbstractSSTableSimpleWriter writer = sorted
? new SSTableSimpleWriter(cfs.getDirectories().getDirectoryForNewSSTables(), cfs.metadata, preparedInsert.updatedColumns(), -1)
: new SSTableSimpleUnsortedWriter(cfs.getDirectories().getDirectoryForNewSSTables(), cfs.metadata, preparedInsert.updatedColumns(), bufferSizeInMiB);
if (format != null)
writer.setSSTableFormatType(format);
writer.setRangeAwareWriting(makeRangeAware);View on GitHub (pinned to 88fd0f6a0e)