{"record":{"id":"03fc3c509c81865f","repo":"apache/cassandra","slug":"no-insert-statement-specified-you-should-provide","errorCode":null,"errorMessage":"No insert statement specified, you should provide an insert statement through using()","messagePattern":"No insert statement specified, you should provide an insert statement through using\\(\\)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"tools/stress/src/org/apache/cassandra/io/sstable/StressCQLSSTableWriter.java","lineNumber":581,"sourceCode":"         * <p>\n         * Note that if used, some option like withBufferSizeInMiB will be ignored.\n         *\n         * @return this builder.\n         */\n        public Builder sorted()\n        {\n            this.sorted = true;\n            return this;\n        }\n\n        public StressCQLSSTableWriter build()\n        {\n            if (directoryList.isEmpty() && cfs == null)\n                throw new IllegalStateException(\"No output directories specified, you should provide a directory with inDirectory()\");\n            if (schemaStatement == null && cfs == null)\n                throw new IllegalStateException(\"Missing schema, you should provide the schema for the SSTable to create with forTable()\");\n            if (insertStatement == null)\n                throw new IllegalStateException(\"No insert statement specified, you should provide an insert statement through using()\");\n\n            synchronized (StressCQLSSTableWriter.class)\n            {\n                if (cfs == null)\n                    cfs = createOfflineTable(schemaStatement, typeStatements, directoryList);\n\n                if (partitioner == null)\n                    partitioner = cfs.getPartitioner();\n\n                UpdateStatement preparedInsert = prepareInsert();\n                AbstractSSTableSimpleWriter writer = sorted\n                                                     ? new SSTableSimpleWriter(cfs.getDirectories().getDirectoryForNewSSTables(), cfs.metadata, preparedInsert.updatedColumns(), -1)\n                                                     : new SSTableSimpleUnsortedWriter(cfs.getDirectories().getDirectoryForNewSSTables(), cfs.metadata, preparedInsert.updatedColumns(), bufferSizeInMiB);\n\n                if (format != null)\n                    writer.setSSTableFormatType(format);\n\n                writer.setRangeAwareWriting(makeRangeAware);","sourceCodeStart":563,"sourceCodeEnd":599,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/tools/stress/src/org/apache/cassandra/io/sstable/StressCQLSSTableWriter.java#L563-L599","documentation":"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.","triggerScenarios":"Calling build() without ever invoking using(...) on the Builder.","commonSituations":"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).","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."],"exampleFix":"// before\nbuilder.forTable(schema).build();\n// after\nbuilder.forTable(schema)\n       .using(\"INSERT INTO ks.tbl (k, v) VALUES (?, ?)\")\n       .build();","handlingStrategy":"validation","validationCode":"if (insertStmt == null || insertStmt.isBlank()) throw new IllegalStateException(\"using() required before build()\");\nbuilder.using(insertStmt);","typeGuard":null,"tryCatchPattern":"try { writer = builder.build(); }\ncatch (IllegalStateException e) { throw new IllegalStateException(\"supply insert via using(): \" + e.getMessage(), e); }","preventionTips":["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."],"tags":["sstable","builder","validation"],"backgroundTag":"missing-required-argument","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}