fix(ast): replace DescribeStatement stubs with UnsupportedStatement, fix extraction gaps#511
Merged
ajitpratap0 merged 1 commit intomainfrom Apr 12, 2026
Merged
Conversation
…fix extraction gaps Addresses multiple issues from the v1.14.0 comprehensive project review: P0 — Critical: - Add UnsupportedStatement AST node with Kind and RawSQL fields to replace DescribeStatement misuse for Snowflake stubs (USE, COPY INTO, PUT, GET, LIST, REMOVE, CREATE STAGE/STREAM/TASK/PIPE/etc.) - Add EXTRACT(field FROM source) parser support (was missing entirely) - Fix all 7 extraction gap tests (CASE, CAST, IN, BETWEEN, EXTRACT, recursive CTEs) — previously t.Skip() stubs, now passing P1 — High: - Add AST.HasUnsupportedStatements() for stub detection - Formatter emits "-- UNSUPPORTED: ..." comment for unmodeled statements instead of producing corrupt SQL - Remove stale "CREATE TABLE not implemented" comment from coverage tests - Add TODO(v2-cleanup) markers to 5 overlapping coverage test files P2 — Medium: - Reconcile Validate() empty-input behavior (parser.ValidateBytes now rejects empty input, matching gosqlx.Validate) - Fix ParseBytes string→byte→string round-trip (now threads []byte directly to tokenizer) - Deprecate pkg/sql/monitor in favor of pkg/metrics (v2.0 removal) - Add v2.0 removal timeline to 3 deprecated parser APIs All tests pass with -race across the full project (20 files, +361/-103). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Claude finished @ajitpratap0's task —— View job Code Review for PR #511Reviewing this comprehensive quality sweep that addresses architectural, QA, and DX issues. Let me analyze the changes across the 20 files. Todo List:
🟢 Excellent Implementation QualityAST Architecture
Parser Improvements
Formatter Excellence
Test Coverage Improvements
🟡 Breaking Changes - Well Handled1. ValidateBytes Empty Input (Minor)// Before: ValidateBytes("") returned nil
// After: ValidateBytes("") returns errorImpact: Low - Empty SQL should fail validation 2. Snowflake Statement Types (Major)// Before: USE statement → *ast.DescribeStatement
// After: USE statement → *ast.UnsupportedStatementImpact: High for Snowflake users doing type assertions 🟢 Security & Performance
🟢 Architecture Benefits
Minor Observations
Recommendation: APPROVE ✅This is exemplary work:
The PR successfully transforms architectural stubs into production-ready functionality while maintaining the library's performance characteristics. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Comprehensive quality sweep addressing architectural, QA, and DX issues identified in the v1.14.0 project review. This PR touches 20 files across the AST, parser, formatter, and gosqlx packages.
P0 — Critical
UnsupportedStatementAST node: Replaces misuse ofDescribeStatementfor Snowflake stubs (USE, COPY INTO, PUT, GET, LIST, REMOVE, CREATE STAGE/STREAM/TASK/PIPE/etc). Consumers doingswitch stmt.(type)can now distinguish these from real DESCRIBE statements. Includes pool (Get/Put),TokenLiteral(), andChildren().parseExtractExpression()forEXTRACT(YEAR FROM expr)syntax — was completely missing, causing parse failures.t.Skip()stubs inextract_test.goreplaced with real passing tests for CASE, CAST, IN, BETWEEN, EXTRACT, and recursive CTEs.P1 — High
AST.HasUnsupportedStatements(): New method to detect stub statements in parsed output.-- UNSUPPORTED: {RawSQL}comment instead of producing corrupt SQL (e.g.,DESCRIBE COPYforCOPY INTO).TODO(v2-cleanup)markers to 5 overlapping parser coverage files (4,286 lines across 51 test functions).P2 — Medium
Validate()reconciled:parser.ValidateBytesnow rejects empty input, matchinggosqlx.Validatebehavior.ParseBytesfixed: Threads[]bytedirectly to tokenizer instead of[]byte→string→[]byteround-trip.pkg/sql/monitordeprecated: Added deprecation notice pointing topkg/metrics, targeting v2.0 removal.Parse([]token.Token),ParseFromModelTokensWithPositions,ConversionResult.PositionMapping) now have "Scheduled for removal in v2.0".Changes
pkg/sql/ast/ast.goUnsupportedStatementtype +AST.HasUnsupportedStatements()pkg/sql/ast/pool.goReleaseStatementcase,Get/PutforUnsupportedStatementpkg/sql/ast/pool_ddl_test.goUnsupportedStatementpkg/sql/parser/parser.goparseSnowflakeUseStatementandparseSnowflakeStageStatementnow produceUnsupportedStatement; deprecation timeline on 3 APIspkg/sql/parser/ddl.goUnsupportedStatementwith captured raw SQLpkg/sql/parser/expressions_complex.goparseExtractExpression()pkg/sql/parser/expressions_literal.gopkg/sql/parser/validate.gopkg/sql/parser/validate_test.gopkg/formatter/render.goUnsupportedStatementcase inFormatStatementpkg/formatter/render_ddl.gorenderUnsupported()— emits SQL commentpkg/gosqlx/gosqlx.goParseBytesthreads bytes directlypkg/gosqlx/extract.gopkg/gosqlx/extract_test.got.Skip()stubs → real passing testspkg/sql/monitor/doc.goTODO(v2-cleanup)markersTest Plan
go build ./...— cleango vet ./...— cleango test -race -timeout 120s ./...— all packages pass, zero failuresSELECT EXTRACT(YEAR FROM created_at) FROM ordersUnsupportedStatementinstead ofDescribeStatement-- UNSUPPORTED: ...comments for stub statementsValidate("")returns error consistently at both API levelsDescribeStatementusage for real MySQL DESCRIBE/DESC unchangedBreaking Changes
parser.ValidateBytes("")now returns an error instead ofnil. This matchesgosqlx.Validate("")which already rejected empty input. Callers that relied on empty-input-is-valid should add an explicit check before calling.*ast.DescribeStatement→*ast.UnsupportedStatement. Code doingstmt.(*ast.DescribeStatement)on Snowflake USE/COPY/PUT/GET/etc. will need updating. TheDescribeStatementtype is preserved for actual MySQL DESCRIBE/DESC/EXPLAIN commands.🤖 Generated with Claude Code