Draft
Conversation
This commit adds comprehensive DuckDB support to sqlc using a database-backed approach with required analyzer, similar to PostgreSQL's optional analyzer pattern but made mandatory for DuckDB. Key features: - Database-backed catalog using DuckDB connections - Required analyzer for type inference and schema information - TiDB parser for SQL parsing (shared with MySQL engine) - DuckDB reserved keywords implementation - Type normalization for DuckDB-specific types - Example project demonstrating basic usage Implementation details: - Parser: Uses TiDB parser, supports -- and /* */ comments - Catalog: Minimal implementation, no pre-generated types - Analyzer: Required component, connects via go-duckdb driver - Converter: Reuses Dolphin/MySQL AST converter - Reserved keywords: Based on DuckDB 1.3.0 specification Files created: - internal/engine/duckdb/parse.go - Parser implementation - internal/engine/duckdb/catalog.go - Minimal catalog - internal/engine/duckdb/convert.go - AST converter - internal/engine/duckdb/reserved.go - Reserved keywords - internal/engine/duckdb/analyzer/analyze.go - Database analyzer - examples/duckdb/basic/ - Example project - DUCKDB_SUPPORT.md - Comprehensive documentation Files modified: - internal/config/config.go - Added EngineDuckDB constant - internal/compiler/engine.go - Registered DuckDB with analyzer - go.mod - Added github.com/marcboeker/go-duckdb v1.8.5 Requirements: - Database connection is required (not optional) - Configuration must include database.uri parameter - Run 'go mod tidy' to download dependencies (network required) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
… only DuckDB now uses a minimal pass-through parser instead of the TiDB parser. All SQL parsing, validation, and type checking happens directly in the DuckDB database via the analyzer. This ensures 100% compatibility with DuckDB syntax without maintaining a separate parser. Changes: - Removed TiDB parser dependency from parse.go - Parser now returns minimal TODO AST nodes - Deleted convert.go (AST conversion not needed) - Database handles all SQL validation via PREPARE/DESCRIBE - Updated documentation to reflect database-only validation approach Benefits: - No shared parser with MySQL/Dolphin engine - Perfect DuckDB syntax compatibility - Simpler codebase with fewer dependencies - All validation happens where it should: in the database The analyzer is now solely responsible for: - Parsing SQL via DuckDB's native parser - Validating queries against the schema - Extracting column and parameter type information - Normalizing DuckDB types to sqlc types 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
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.
No description provided.