Repository navigation
fix(parser): format data branch statements - #26560
Conversation
0e9ad2b to
51b63f2
Compare
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
Fixed the requested formatter closure in commit
Both reported cases failed before the fix and now pass. The four directly affected tests passed independently with deterministic CGo |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Re-reviewed current head 634d700818777bcb2e8e9702feeb4a8b3c1df84f.
The previous DATA BRANCH PICK parse → format → parse closure issue is resolved: PICK now uses the shared identifier/string quoting scope, snapshot names are restored as escaped SQL string literals, and the new tests verify reparsed semantic fields. I also reviewed the complete formatter/grammar closure and unhappy paths; no merge-blocking correctness, lifecycle, compatibility, or performance issue remains.
Independent verification passed: build, vet, focused round-trip tests, full owning-package tests in normal and race modes, plus repeated direct race tests.
Merge Queue Status
This pull request spent 43 minutes 22 seconds in the queue, including 42 minutes 21 seconds running CI. Required conditions to merge
|
### Root cause The parser creates valid AST nodes for `DATA BRANCH DELETE TABLE`, `CREATE DATABASE`, `DELETE DATABASE`, `DIFF`, and `MERGE`, but their `Format` and `TypeName` methods still panic with `implement me`. Existing lifecycle tests explicitly expected those panics. `CREATE TABLE` had been implemented separately on current `main` after the issue was filed. `DATA BRANCH PICK` did not panic, but it was the only formatter outside the shared data-branch formatting scope. Consequently reserved or escaped table identifiers were emitted without safe quoting. Its `BETWEEN SNAPSHOT` values were also written as raw SQL text, so parsed names containing whitespace or apostrophes produced SQL that `ParseOne` rejected. ### Changes - Implement SQL formatting and type names for the five previously unimplemented data-branch statement nodes. - Format the complete data-branch family, including `PICK`, through one shared identifier and string quoting scope. - Restore `PICK` snapshot names as canonical SQL string literals and preserve escaped identifiers. - Format every `DIFF` output form (`AS`, `FILE`, `LIMIT`, `COUNT`, and `SUMMARY`), including `LIMIT 0` and an empty file literal. - Reuse shared string-literal and conflict-option formatters instead of duplicating restoration logic. - Replace panic-expecting lifecycle assertions and add parser-format-parser round-trip coverage for all affected statements, `PICK` escaped identifiers and string snapshots, and option boundaries. - Assert reparsed `PICK` table, snapshot, keys, and conflict-option semantics. ### Tests - Pre-fix reproduction: `TestDataBranchPickFormatRoundTrip` failed both reported cases with malformed identifier and raw snapshot output. - `go build ./pkg/sql/parsers/tree ./pkg/sql/parsers/dialect/mysql` - `go vet ./pkg/sql/parsers/tree ./pkg/sql/parsers/dialect/mysql` - `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=240s ./pkg/sql/parsers/tree ./pkg/sql/parsers/dialect/mysql` - Focused deterministic CGo race stress: `TestDataBranchPickFormatRoundTrip`, `TestDataBranchStatementFormatRoundTrip`, `TestDataBranchPickFormat`, and `TestDataBranchDiffFormatOutputOptions` each passed independently with `-race -count=100` (`T=0`, 30-second adaptive budget, `N=100`). - `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=300s ./pkg/sql/parsers/tree ./pkg/sql/parsers/dialect/mysql` All verification is against current `main` (`ffad68fdb`). ### BVT and residual risk BVT is not applicable because executing a valid data-branch statement does not call the AST formatter; it cannot reproduce this failure. Focused AST and parser round-trip unit tests exercise the failing ownership boundary directly. No residual functional risk is known; the change is limited to SQL restoration and its tests. Approved by: @XuPeng-SH
### Root cause The parser creates valid AST nodes for `DATA BRANCH DELETE TABLE`, `CREATE DATABASE`, `DELETE DATABASE`, `DIFF`, and `MERGE`, but their `Format` and `TypeName` methods still panic with `implement me`. Existing lifecycle tests explicitly expected those panics. `CREATE TABLE` had been implemented separately on current `main` after the issue was filed. `DATA BRANCH PICK` did not panic, but it was the only formatter outside the shared data-branch formatting scope. Consequently reserved or escaped table identifiers were emitted without safe quoting. Its `BETWEEN SNAPSHOT` values were also written as raw SQL text, so parsed names containing whitespace or apostrophes produced SQL that `ParseOne` rejected. ### Changes - Implement SQL formatting and type names for the five previously unimplemented data-branch statement nodes. - Format the complete data-branch family, including `PICK`, through one shared identifier and string quoting scope. - Restore `PICK` snapshot names as canonical SQL string literals and preserve escaped identifiers. - Format every `DIFF` output form (`AS`, `FILE`, `LIMIT`, `COUNT`, and `SUMMARY`), including `LIMIT 0` and an empty file literal. - Reuse shared string-literal and conflict-option formatters instead of duplicating restoration logic. - Replace panic-expecting lifecycle assertions and add parser-format-parser round-trip coverage for all affected statements, `PICK` escaped identifiers and string snapshots, and option boundaries. - Assert reparsed `PICK` table, snapshot, keys, and conflict-option semantics. ### Tests - Pre-fix reproduction: `TestDataBranchPickFormatRoundTrip` failed both reported cases with malformed identifier and raw snapshot output. - `go build ./pkg/sql/parsers/tree ./pkg/sql/parsers/dialect/mysql` - `go vet ./pkg/sql/parsers/tree ./pkg/sql/parsers/dialect/mysql` - `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=240s ./pkg/sql/parsers/tree ./pkg/sql/parsers/dialect/mysql` - Focused deterministic CGo race stress: `TestDataBranchPickFormatRoundTrip`, `TestDataBranchStatementFormatRoundTrip`, `TestDataBranchPickFormat`, and `TestDataBranchDiffFormatOutputOptions` each passed independently with `-race -count=100` (`T=0`, 30-second adaptive budget, `N=100`). - `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=300s ./pkg/sql/parsers/tree ./pkg/sql/parsers/dialect/mysql` All verification is against current `main` (`ffad68fdb`). ### BVT and residual risk BVT is not applicable because executing a valid data-branch statement does not call the AST formatter; it cannot reproduce this failure. Focused AST and parser round-trip unit tests exercise the failing ownership boundary directly. No residual functional risk is known; the change is limited to SQL restoration and its tests. Approved by: @XuPeng-SH
### Root cause The parser creates valid AST nodes for `DATA BRANCH DELETE TABLE`, `CREATE DATABASE`, `DELETE DATABASE`, `DIFF`, and `MERGE`, but their `Format` and `TypeName` methods still panic with `implement me`. Existing lifecycle tests explicitly expected those panics. `CREATE TABLE` had been implemented separately on current `main` after the issue was filed. `DATA BRANCH PICK` did not panic, but it was the only formatter outside the shared data-branch formatting scope. Consequently reserved or escaped table identifiers were emitted without safe quoting. Its `BETWEEN SNAPSHOT` values were also written as raw SQL text, so parsed names containing whitespace or apostrophes produced SQL that `ParseOne` rejected. ### Changes - Implement SQL formatting and type names for the five previously unimplemented data-branch statement nodes. - Format the complete data-branch family, including `PICK`, through one shared identifier and string quoting scope. - Restore `PICK` snapshot names as canonical SQL string literals and preserve escaped identifiers. - Format every `DIFF` output form (`AS`, `FILE`, `LIMIT`, `COUNT`, and `SUMMARY`), including `LIMIT 0` and an empty file literal. - Reuse shared string-literal and conflict-option formatters instead of duplicating restoration logic. - Replace panic-expecting lifecycle assertions and add parser-format-parser round-trip coverage for all affected statements, `PICK` escaped identifiers and string snapshots, and option boundaries. - Assert reparsed `PICK` table, snapshot, keys, and conflict-option semantics. ### Tests - Pre-fix reproduction: `TestDataBranchPickFormatRoundTrip` failed both reported cases with malformed identifier and raw snapshot output. - `go build ./pkg/sql/parsers/tree ./pkg/sql/parsers/dialect/mysql` - `go vet ./pkg/sql/parsers/tree ./pkg/sql/parsers/dialect/mysql` - `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=240s ./pkg/sql/parsers/tree ./pkg/sql/parsers/dialect/mysql` - Focused deterministic CGo race stress: `TestDataBranchPickFormatRoundTrip`, `TestDataBranchStatementFormatRoundTrip`, `TestDataBranchPickFormat`, and `TestDataBranchDiffFormatOutputOptions` each passed independently with `-race -count=100` (`T=0`, 30-second adaptive budget, `N=100`). - `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=300s ./pkg/sql/parsers/tree ./pkg/sql/parsers/dialect/mysql` All verification is against current `main` (`ffad68fdb`). ### BVT and residual risk BVT is not applicable because executing a valid data-branch statement does not call the AST formatter; it cannot reproduce this failure. Focused AST and parser round-trip unit tests exercise the failing ownership boundary directly. No residual functional risk is known; the change is limited to SQL restoration and its tests. Approved by: @XuPeng-SH
What type of PR is this?
Which issue(s) this PR fixes:
Closes #26032
What this PR does / why we need it:
Root cause
The parser creates valid AST nodes for
DATA BRANCH DELETE TABLE,CREATE DATABASE,DELETE DATABASE,DIFF, andMERGE, but theirFormatandTypeNamemethods still panic withimplement me. Existing lifecycle tests explicitly expected those panics.CREATE TABLEhad been implemented separately on currentmainafter the issue was filed.DATA BRANCH PICKdid not panic, but it was the only formatter outside the shared data-branch formatting scope. Consequently reserved or escaped table identifiers were emitted without safe quoting. ItsBETWEEN SNAPSHOTvalues were also written as raw SQL text, so parsed names containing whitespace or apostrophes produced SQL thatParseOnerejected.Changes
PICK, through one shared identifier and string quoting scope.PICKsnapshot names as canonical SQL string literals and preserve escaped identifiers.DIFFoutput form (AS,FILE,LIMIT,COUNT, andSUMMARY), includingLIMIT 0and an empty file literal.PICKescaped identifiers and string snapshots, and option boundaries.PICKtable, snapshot, keys, and conflict-option semantics.Tests
TestDataBranchPickFormatRoundTripfailed both reported cases with malformed identifier and raw snapshot output.go build ./pkg/sql/parsers/tree ./pkg/sql/parsers/dialect/mysqlgo vet ./pkg/sql/parsers/tree ./pkg/sql/parsers/dialect/mysql.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=240s ./pkg/sql/parsers/tree ./pkg/sql/parsers/dialect/mysqlTestDataBranchPickFormatRoundTrip,TestDataBranchStatementFormatRoundTrip,TestDataBranchPickFormat, andTestDataBranchDiffFormatOutputOptionseach passed independently with-race -count=100(T=0, 30-second adaptive budget,N=100)..agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=300s ./pkg/sql/parsers/tree ./pkg/sql/parsers/dialect/mysqlAll verification is against current
main(ffad68fdb).BVT and residual risk
BVT is not applicable because executing a valid data-branch statement does not call the AST formatter; it cannot reproduce this failure. Focused AST and parser round-trip unit tests exercise the failing ownership boundary directly. No residual functional risk is known; the change is limited to SQL restoration and its tests.