{"record":{"id":"5659ce7f37c62d29","repo":"apache/cassandra","slug":"could-not-parse-update-query-querystring-5659ce","errorCode":null,"errorMessage":"could not parse update query:${queryString}","messagePattern":"could not parse update query:(.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"tools/stress/src/org/apache/cassandra/stress/operations/userdefined/CASQuery.java","lineNumber":81,"sourceCode":"    private PreparedStatement casReadConditionStatement;\n\n    public CASQuery(Timer timer, StressSettings settings, PartitionGenerator generator, SeedManager seedManager, PreparedStatement statement, ConsistencyLevel cl, ArgSelect argSelect, final String tableName)\n    {\n        super(timer, settings, new DataSpec(generator, seedManager, new DistributionFixed(1), settings.insert.rowPopulationRatio.get(), argSelect == SchemaStatement.ArgSelect.MULTIROW ? statement.getVariables().size() : 1), statement,\n              statement.getVariables().asList().stream().map(ColumnDefinitions.Definition::getName).collect(Collectors.toList()), cl);\n\n        if (argSelect != SchemaStatement.ArgSelect.SAMEROW)\n            throw new IllegalArgumentException(\"CAS is supported only for type 'samerow'\");\n\n        ModificationStatement.Parsed modificationStatement;\n        try\n        {\n            modificationStatement = CQLFragmentParser.parseAnyUnhandled(CqlParser::updateStatement,\n                    statement.getQueryString());\n        }\n        catch (RecognitionException e)\n        {\n            throw new IllegalArgumentException(\"could not parse update query:\" + statement.getQueryString(), e);\n        }\n\n        final List<ColumnCondition.Raw> casConditionList = modificationStatement.getConditions();\n        List<Integer> casConditionIndex = new ArrayList<>();\n\n        boolean first = true;\n        StringBuilder casReadConditionQuery = new StringBuilder();\n        casReadConditionQuery.append(\"SELECT \");\n        for (final ColumnCondition.Raw condition : casConditionList)\n        {\n            if (!condition.containsBindMarkers())\n            {\n                //condition uses static value, ignore it\n                continue;\n            }\n            if (!first)\n            {\n                casReadConditionQuery.append(\", \");","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/tools/stress/src/org/apache/cassandra/stress/operations/userdefined/CASQuery.java#L63-L99","documentation":"CASQuery must parse the prepared statement's query string as an UPDATE statement (via the CQL ANTLR parser) to extract the IF conditions. If the query string cannot be parsed as an update statement, the RecognitionException is wrapped in an IllegalArgumentException including the offending query text.","triggerScenarios":"Using a CAS operation in a stress profile whose prepared statement is not a syntactically valid UPDATE statement (e.g. an INSERT with conditions, a malformed UPDATE, or a SELECT passed where CAS expects UPDATE).","commonSituations":"Typos in the profile's CAS statement; pointing CAS at an INSERT or conditional INSERT statement instead of UPDATE ... IF; version drift between profile CQL syntax and the parser grammar.","solutions":["Ensure the CAS statement is a valid UPDATE ... IF EXISTS / IF col=val query","Validate the CQL statement in cqlsh before adding it to the stress profile","Check the query string for syntax errors (missing commas, wrong keywords)"],"exampleFix":"// before\nstmt: INSERT INTO t (k, v) VALUES (?, ?) IF NOT EXISTS\n// after\nstmt: UPDATE t SET v = ? WHERE k = ? IF v = ?","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { CQLFragmentParser.parseAnyUnhandled(CqlParser::updateStatement, stmt.getQueryString()); }\ncatch (RecognitionException e) { throw new IllegalArgumentException(\"CAS statement must be a valid UPDATE: \" + stmt.getQueryString(), e); }","preventionTips":["Validate CAS CQL statements in cqlsh before adding them to profiles","Use UPDATE ... IF forms only for CAS ops","Keep profile CQL syntax aligned with the target Cassandra version's grammar"],"tags":["cql","parsing","configuration"],"backgroundTag":"invalid-argument-format","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"}