Repository navigation
Conversation
ParserAlterQuery accepts TO SHARD only in the MOVE PART branch and TO TABLE only in the MOVE PARTITION branch, but the MOVE_PARTITION validation in readJSON checked move_destination_type without consulting the part flag. With dialect = clickhouse_json both crossed pairs were therefore admitted. part = true with TABLE reached MergeTreeData::getPartitionIDFromQuery, which downcasts the partition slot with as<ASTPartition &>(); against the part-name ASTLiteral that raised Code: 49. DB::Exception: Bad cast from type DB::ASTLiteral to DB::ASTPartition as a LOGICAL_ERROR, aborting debug and sanitizer builds. part = false with SHARD formatted MOVE PARTITION 1 TO SHARD 'v', which the SQL parser rejects, so formatQueryFromJSON output and the query text propagated to system.query_log and to Keeper for ON CLUSTER DDL could not be parsed back. Both shapes now fail closed with BAD_ARGUMENTS at the deserialization boundary, like the other parser-impossible combinations validated in the same function. The four parser-produced pairings are unaffected and still round-trip. Verified by reverting the source change and confirming both new test rows go red, then restoring it and confirming the suite passes.
|
Workflow [PR], commit [d88abd4] Summary: ✅
AI ReviewSummaryThis PR closes the Final Verdict✅ Approved LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 17/22 (77.27%) · Uncovered code |
CI finish ledger - d88abd4CI has fully finished on this head with no failures to own. The praktika report is
Three CIDB rows for this commit are not failures of this run: Session id: cron:our-pr-ci-monitor:20260812-140000 |
5abf3cd
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed a
LOGICAL_ERROR(Bad cast from type DB::ASTLiteral to DB::ASTPartition) and unparseable formatted SQL when anALTER TABLE ... MOVEcommand deserialized from a JSON AST (dialect = clickhouse_json) paired thePARTform withTO TABLE, or thePARTITIONform withTO SHARD. Such payloads are now rejected withBAD_ARGUMENTS.Description
ParserAlterQueryacceptsTO SHARDonly in theMOVE PARTbranch andTO TABLEonly in theMOVE PARTITIONbranch, so the destination is tied to thepartflag. TheMOVE_PARTITIONvalidation inASTAlterCommand::readJSONswitched onmove_destination_typewithout consultingpart, so both crossed pairs were admitted at the JSON boundary.part = truewithTABLEreachedMergeTreeData::getPartitionIDFromQuery, which downcasts the partition slot withas<ASTPartition &>(). Against the part-nameASTLiteralthat raisedCode: 49 ... Bad cast from type DB::ASTLiteral to DB::ASTPartitionas aLOGICAL_ERROR, aborting debug and sanitizer builds.part = falsewithSHARDformattedMOVE PARTITION 1 TO SHARD 'v', which the SQL parser rejects, soformatQueryFromJSONoutput and the query text propagated tosystem.query_logand to Keeper forON CLUSTERDDL could not be parsed back.Both shapes now fail closed with
BAD_ARGUMENTS, matching the other parser-impossible combinations already validated in the same function. The four parser-produced pairings (PARTwithDISK/VOLUME/SHARD,PARTITIONwithDISK/VOLUME/TABLE) are unaffected and still round-trip.Pre-existing, not a regression: on the parent commit the same payloads were already accepted, and merely formatted different unparseable text.
Regression rows were added to the existing
04350_ast_json_parser_impossible_field_combinationstest. Reverting the source change turns both new rows red; restoring it makes the suite pass.Closes: #114425
Version info
26.8.1.1268(included in26.8and later)