You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(deparser): support ALTER STATISTICS ... RENAME TO - #391
ALTER STATISTICS s1 RENAME TO s2 threw Unsupported RenameStmt renameType: OBJECT_STATISTIC_EXT. It now emits STATISTICS and handles qualified names through the same List path as types and domains. Fixtures cover plain, schema-qualified and quoted names.
This is a fresh version of the rename part of #370, part of constructive-io/constructive-planning#2555. SET STATISTICS DEFAULT / IF EXISTS are separate bugs, tracked in the epic.
Improved formatting for ALTER STATISTICS ... RENAME TO statements with unqualified names, schema-qualified names, and quoted schema or statistics identifiers. Formatted SQL now keeps these names correctly separated and quoted, making rename statements clearer to read across these naming styles.
This PR extends the deparser to handle the renameType statement branch for statistics objects so ALTER STATISTICS ... RENAME TO ... round-trips correctly, and adds fixtures and tests covering both the standard and pretty-print output paths.
Files
Change
packages/deparser/src/deparser.ts
Adds handling of OBJECT_STATISTIC_EXT in the rename statement rendering to emit ALTER STATISTICS <name> RENAME TO <newname>.
No actionable comments were generated in the recent review.
Walkthrough
The deparser now handles ALTER STATISTICS ... RENAME TO statements. It emits the STATISTICS keyword and formats statistics names, including qualified and quoted names. Fixtures and tests cover these name forms.
Changes: Statistics Rename
Layer / File(s)
Summary
Statistics rename support packages/deparser/src/deparser.ts, __fixtures__/kitchen-sink/misc/alter-statistics-rename.sql, packages/deparser/__tests__/kitchen-sink/misc-alter-statistics-rename.test.ts, packages/deparser/__tests__/pretty/alter-statistics-rename.test.ts
RenameStmt now emits STATISTICS for statistics objects and formats qualified names with dotted, conditionally quoted identifiers. Fixtures and tests cover unqualified, public-qualified, and quoted names.
This adds support for ALTER STATISTICS ... RENAME TO in the deparser, with fixtures covering plain, schema-qualified and quoted names. No concrete defects were found, so the merge risk is minimal.
Security architecture risk: Minimal · up to 80264
The change adds SQL rendering support while retaining existing identifier quoting. The inspected path returns SQL text rather than executing it, and no introduced security, ownership, or failure-containment risk was established.
Retained concerns
No architecture-level concerns identified.
Security review details
Security Blast Radius
inferred — The directly established exposure is newly supported SQL generation for caller-supplied statistics-rename ASTs. Actual database execution, credentials, authorization, and tenant scope depend on consumers not established by the supplied relationship evidence.
Trust Boundaries and Controls
inferred — Caller-controlled names enter SQL identifier positions through the existing quoting control rather than raw interpolation in the added List branch. The inspected change enables rendering, not an authorization bypass; no execution boundary is crossed within RenameStmt itself.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: the deparser now supports ALTER STATISTICS ... RENAME TO. The raw summary confirms that RenameStmt maps OBJECT_STATISTIC_EXT to the STATISTICS keyword and that the fix…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: the deparser now supports ALTER STATISTICS ... RENAME TO. The raw summary confirms that RenameStmt maps OBJECT_STATISTIC_EXT to the STATISTICS keyword and that the fixtures and tests cover the rename statements. The title is specific, concise, and matches the PR objectives. It does not mention the separate SET STATISTICS DEFAULT or IF EXISTS bugs, which the PR does not claim to address.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Reviewing files that changed from the base of the PR and between 4ddf1b4 and 8026412.
Files ignored due to path filters: 2
__fixtures__/generated/generated.json is excluded by !**/generated/**, !__fixtures__/generated/**
packages/deparser/__tests__/pretty/__snapshots__/alter-statistics-rename.test.ts.snap is excluded by !**/*.snap, !**/__snapshots__/**
Files selected for processing: 1
packages/deparser/src/deparser.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ALTER STATISTICS s1 RENAME TO s2threwUnsupported RenameStmt renameType: OBJECT_STATISTIC_EXT. It now emitsSTATISTICSand handles qualified names through the same List path as types and domains. Fixtures cover plain, schema-qualified and quoted names.This is a fresh version of the rename part of #370, part of constructive-io/constructive-planning#2555.
SET STATISTICS DEFAULT/IF EXISTSare separate bugs, tracked in the epic.Implemented in session Triage stale open PRs and issues in parser repos
Review with Devin · Open in Devin Desktop
Summary by CodeRabbit
ALTER STATISTICS ... RENAME TOstatements with unqualified names, schema-qualified names, and quoted schema or statistics identifiers. Formatted SQL now keeps these names correctly separated and quoted, making rename statements clearer to read across these naming styles.