{"record":{"id":"2b1e6dd2f6c26772","repo":"apache/cassandra","slug":"variable-column-counts-are-not-implemented-for-cql","errorCode":null,"errorMessage":"Variable column counts are not implemented for CQL","messagePattern":"Variable column counts are not implemented for CQL","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"tools/stress/src/org/apache/cassandra/stress/operations/predefined/CqlOperation.java","lineNumber":57,"sourceCode":"import org.apache.cassandra.transport.SimpleClient;\nimport org.apache.cassandra.transport.messages.ResultMessage;\nimport org.apache.cassandra.utils.ByteBufferUtil;\n\npublic abstract class CqlOperation<V> extends PredefinedOperation\n{\n\n    public static final ByteBuffer[][] EMPTY_BYTE_BUFFERS = new ByteBuffer[0][];\n    public static final byte[][] EMPTY_BYTE_ARRAYS = new byte[0][];\n\n    protected abstract List<Object> getQueryParameters(byte[] key);\n    protected abstract String buildQuery();\n    protected abstract CqlRunOp<V> buildRunOp(QueryExecutor<?> queryExecutor, List<Object> params, ByteBuffer key);\n\n    public CqlOperation(Command type, Timer timer, PartitionGenerator generator, SeedManager seedManager, StressSettings settings)\n    {\n        super(type, timer, generator, seedManager, settings);\n        if (settings.columns.variableColumnCount)\n            throw new IllegalStateException(\"Variable column counts are not implemented for CQL\");\n    }\n\n    protected CqlRunOp<V> run(final QueryExecutor<?> queryExecutor, final List<Object> queryParams, final ByteBuffer key) throws IOException\n    {\n        final CqlRunOp<V> op = buildRunOp(queryExecutor, queryParams, key);\n        timeWithRetry(op);\n        return op;\n    }\n\n    protected void run(final QueryExecutor<?> queryExecutor) throws IOException\n    {\n        final byte[] key = getKey().array();\n        final List<Object> queryParams = getQueryParameters(key);\n        run(queryExecutor, queryParams, ByteBuffer.wrap(key));\n    }\n\n    // Classes to process Cql results\n","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/tools/stress/src/org/apache/cassandra/stress/operations/predefined/CqlOperation.java#L39-L75","documentation":"CqlOperation's constructor rejects stress configurations that request a variable number of columns per row, because the CQL statement templates (prepared queries) are built for a fixed column count. Since this cannot be honored for CQL-based operations, it throws IllegalStateException early rather than failing mid-run.","triggerScenarios":"Running any CQL-based cassandra-stress operation (cql, or predefined CQL ops) with -col 'n=FIXED(10,50)' i.e. variableColumnCount enabled in the column settings.","commonSituations":"Reusing a stress profile or command line tuned for Thrate/legacy ops with variable column counts against CQL ops; attempting to simulate varied row sizes with CQL stress.","solutions":["Use a fixed column count for CQL ops, e.g. -col n=FIXED(10) or just -col n=10","Switch to user-defined (profile-based) stress where variable sizing can be modeled differently","Drop the variable column count option from the -col spec"],"exampleFix":"// before\nstress write -col n=FIXED(5,20)\n// after\nstress write -col n=FIXED(5)","handlingStrategy":"validation","validationCode":"if (settings.columns.variableColumnCount)\n    throw new IllegalStateException(\"Use a fixed column count for CQL stress ops\");","typeGuard":null,"tryCatchPattern":"try { new CqlOperation(type, timer, generator, seedManager, settings); } catch (IllegalStateException e) { log.error(\"Reconfigure -col with n=FIXED(k)\"); }","preventionTips":["Never use variableColumnCount with CQL-based stress operations","Use -col n=FIXED(k) for CQL ops","Model row-size variation via other means (e.g. multiple profiles)"],"tags":["cli","cql","unsupported-feature"],"backgroundTag":"unsupported-operation","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"}