apache/cassandra · error · IllegalStateException
Missing schema, you should provide the schema for the SSTabl
Error message
Missing schema, you should provide the schema for the SSTable to create with forTable()
What it means
StressCQLSSTableWriter.Builder.build() requires the target table schema, normally supplied via forTable(schemaStatement). It throws IllegalStateException when no schema statement was provided and no pre-existing column family (cfs) is available, so the writer cannot determine the SSTable layout.
Source
Thrown at tools/stress/src/org/apache/cassandra/io/sstable/StressCQLSSTableWriter.java:579
* the rows in order, which is rarely the case. If you can provide the
* rows in order however, using this sorted might be more efficient.
* <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);View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Add .forTable("CREATE TABLE ...") with the full CREATE TABLE statement to the builder.
- Load the CREATE TABLE statement from your schema files if it is maintained externally.
- Include any needed type statements via withType(...) for custom types used by the table.
- Alternatively, use the variant that builds against an existing column family.
Example fix
// before
builder.using("INSERT ...").build();
// after
builder.forTable("CREATE TABLE ks.tbl (k text PRIMARY KEY, v int)")
.using("INSERT INTO ks.tbl (k, v) VALUES (?, ?)")
.build(); Defensive patterns
Strategy: validation
Validate before calling
if (createTableStmt == null || createTableStmt.isBlank()) throw new IllegalStateException("forTable() required before build()");
builder.forTable(createTableStmt); Try / catch
try { writer = builder.build(); }
catch (IllegalStateException e) { throw new IllegalStateException("supply schema via forTable(): " + e.getMessage(), e); } Prevention
- Keep CREATE TABLE statements in versioned schema files and load them.
- Always pair forTable() with matching using() insert in a shared factory.
- Include withType() for custom types.
- Validate the schema string parses before building.
When it happens
Trigger: Calling build() without forTable(...) (or without an existing cfs) on the Builder.
Common situations: Building a writer only from an INSERT statement assuming schema is inferred; copying example code and deleting the forTable line; generating SSTables for a table whose CREATE statement lives in a file never loaded.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- Missing schema, you should provide the schema for the SSTabl
- Unknown column <name> during deserialization
- No ouptut directory specified, you should provide a director
- No modification (INSERT/UPDATE/DELETE) statement specified,
- Clustering block upper bits (those not associated with keys)
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/39b04aef10519b34.
Report an issue: GitHub.