Add intelligent SQL auto-completion with prioritization#3
Open
tobias-fire wants to merge 4 commits intotobias/syntax-highlightingfrom
Open
Add intelligent SQL auto-completion with prioritization#3tobias-fire wants to merge 4 commits intotobias/syntax-highlightingfrom
tobias-fire wants to merge 4 commits intotobias/syntax-highlightingfrom
Conversation
Implements regex-based syntax highlighting for SQL queries in the
interactive REPL mode with industry-standard color scheme.
Features:
- Keywords (SELECT, FROM, WHERE): Bright Blue
- Functions (COUNT, AVG): Bright Cyan
- Strings ('text'): Bright Yellow
- Numbers (42, 3.14): Bright Magenta
- Comments (-- text): Bright Black (gray)
- Operators: Default (subtle)
Configuration:
- Auto-enabled in interactive TTY mode
- Disabled via --no-color flag
- Respects NO_COLOR environment variable
- Auto-disabled for piped/redirected output
Implementation:
- Regex-based highlighting (no new dependencies)
- 13 comprehensive unit tests
- Graceful error handling
- Colorblind-accessible color scheme based on DuckDB, pgcli, and
accessibility research
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implement context-aware auto-completion that suggests table names and column names from the database schema. The completion system queries information_schema on startup and caches results for fast lookups. Key features: - Auto-complete table names and column names - Async schema cache refresh (non-blocking startup) - Support for message-based query response format - Configurable via --no-completion and --completion-cache-ttl flags - Runtime control with 'set completion = on/off' - Manual refresh with \refresh command Implementation details: - New completion module with SqlCompleter, SchemaCache, and context detector - Queries information_schema.tables, columns, and routines - Thread-safe cache using Arc<RwLock<T>> - Graceful error handling and fallback Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implements context-aware, frequency-based suggestion ordering with schema exploration support. Tables and columns now appear based on query context, usage frequency, and relevance, with system schemas appropriately deprioritized. Schema names can be completed directly and typing 'schema.' shows all tables in that schema. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implements auto-completion for SQL functions with lowest priority (below columns, above system schemas). Functions complete with opening parenthesis for immediate argument typing. Operators are filtered out using routine_type != 'OPERATOR' from information_schema.routines. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
6a2b45c to
6a747d9
Compare
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
Adds intelligent SQL auto-completion to the REPL with context-aware prioritization and usage tracking.
Features
1. SQL Auto-Completion
2. Intelligent Prioritization (5-tier system)
3. Context-Aware Suggestions
4. Usage Tracking
5. Schema Exploration
schema_name.to see all tables in that schematable_name.to see all columns in that tableArchitecture
New Components
src/completion/usage_tracker.rs- Tracks table/column/function usage frequencysrc/completion/priority_scorer.rs- Calculates priority scores (5-tier system)src/completion/context_analyzer.rs- Extracts tables from SQL statementsModified Components
src/completion/mod.rs- Integrated scoring and sortingsrc/completion/schema_cache.rs- Added schemas and functions supportsrc/main.rs- Initialize UsageTrackersrc/query.rs- Track successful queriessrc/context.rs- Store usage tracker referenceTesting
Examples
No table context - typing
SELECT u<Tab>:Tables appear first, then columns.
With table context - typing
SELECT * FROM users WHERE u<Tab>:Columns from
usersappear first.Schema exploration - typing
information_schema.<Tab>:Function completion - typing
len<Tab>:🤖 Generated with Claude Code