sql-cli 1.69.0

SQL query tool for CSV/JSON with both interactive TUI and non-interactive CLI modes - perfect for exploration and automation
Documentation
# SQL CLI - Project Summary

**Last Updated**: 2025-10-02
**Version**: 1.56.0
**Strategic Focus**: Neovim Plugin Excellence

## ๐ŸŽฏ What Is This?

Fast in-memory SQL query tool with dual interface:
- **Neovim Plugin** (Primary) - Data exploration in your editor
- **CLI/TUI** (Secondary) - Standalone terminal tool

**Core Value**: Query CSV/JSON files and HTTP endpoints with SQL, instantly.

## ๐Ÿ“Š Current State (October 2025)

### โœ… What Works Great

**SQL Engine**:
- โœ… SELECT, WHERE, JOIN, GROUP BY, ORDER BY, LIMIT
- โœ… 100+ SQL functions (math, string, date, conversion)
- โœ… Window functions (ROW_NUMBER, RANK, LAG, LEAD, etc.)
- โœ… CTEs (Common Table Expressions)
- โœ… WEB CTEs (query HTTP APIs as tables)
- โœ… Performance: 8ms @ 100K rows for simple queries

**Neovim Plugin**:
- โœ… Smart column expansion (`\sE`) - discovers columns from CTEs
- โœ… Distinct value analysis (`\srD`) - instant cardinality
- โœ… Export (TSV/CSV/HTML) to clipboard or browser
- โœ… SQL refactoring tools (CASE generation, banding)
- โœ… Fuzzy search through results
- โœ… Cross-buffer operation

**Data Sources**:
- โœ… CSV files
- โœ… JSON files
- โœ… HTTP endpoints (WEB CTEs)
- โœ… FIX protocol proxy integration

### ๐Ÿ”ง Active Development

**This Week (P0)**:
- Fix fuzzy search being too permissive
- Document FIX proxy usage with examples

**This Month (P1)**:
- Column hide/show feature
- Smart expansion edge case improvements

**Next 3 Months (P2)**:
- Plugin data model (stop parsing buffers)
- Multiple rendering styles
- WEB CTE authentication

### ๐Ÿšซ Explicitly Not Doing

- โŒ Major TUI enhancements (plugin superseded it)
- โŒ CUDA/GPU acceleration (no performance need)
- โŒ Parallel query execution (not a bottleneck)
- โŒ Type system overhaul (works well enough)

## ๐Ÿ“ˆ Performance Characteristics

**Tested @ 100K rows**:
- Simple SELECT: **8ms**
- JOINs: **<40ms**
- GROUP BY: **~500ms**
- Window functions: **~1.2s**

**Sufficient for**: <30K row datasets (primary use case)

## ๐Ÿ—บ๏ธ Architecture

```
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚           Neovim Plugin (Lua)              โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚ Commands โ”‚  โ”‚ Keybinds โ”‚  โ”‚ Renderersโ”‚ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚       โ”‚             โ”‚              โ”‚       โ”‚
โ”‚       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜       โ”‚
โ”‚                     โ–ผ                       โ”‚
โ”‚            โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”             โ”‚
โ”‚            โ”‚   State Layer   โ”‚ โ† Future    โ”‚
โ”‚            โ”‚  (QueryResult)  โ”‚   data modelโ”‚
โ”‚            โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜             โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                      โ–ผ
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ”‚   sql-cli (Rust Core)   โ”‚
        โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
        โ”‚  โ”‚  SQL Parser      โ”‚   โ”‚
        โ”‚  โ”‚  Query Executor  โ”‚   โ”‚
        โ”‚  โ”‚  Data Sources    โ”‚   โ”‚
        โ”‚  โ”‚  Function Reg.   โ”‚   โ”‚
        โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                      โ”‚
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ–ผ             โ–ผ             โ–ผ
    CSV Files    JSON Files    HTTP APIs
```

## ๐Ÿ“š Documentation Structure

**Start Here**:
- [START_HERE.md]START_HERE.md - Onboarding guide (15 min)
- [ROADMAP_2025.md]ROADMAP_2025.md - Strategy & priorities
- [PRIORITIZED_TASKS.md]PRIORITIZED_TASKS.md - Current work

**Active Development**:
- [PLUGIN_DATA_MODEL_EVOLUTION.md]PLUGIN_DATA_MODEL_EVOLUTION.md - Architecture evolution
- [NVIM_SMART_COLUMN_COMPLETION.md]NVIM_SMART_COLUMN_COMPLETION.md - Column features
- [PERFORMANCE.md]PERFORMANCE.md - Benchmarks

**Reference**:
- [FUNCTION_REFERENCE.md]FUNCTION_REFERENCE.md - SQL functions
- [INDEX.md]INDEX.md - Find anything
- `archive/` - Historical docs (~193 docs)

## ๐ŸŽจ Design Philosophy

**"Make the common case fast"**

1. **Plugin over TUI** - Leverage 30 years of editor evolution
2. **Simple over complex** - Unless complexity is hidden
3. **Fast feedback** - Milliseconds, not seconds
4. **Clear errors** - Tell users what went wrong
5. **Composability** - Small pieces, loosely joined

**Decision Framework**:
```
Does it improve daily workflow?     โ†’ P0/P1
Is it plugin-related?               โ†’ Higher priority
Is it TUI-related?                  โ†’ Lower priority
Needs >30K rows to matter?          โ†’ Defer
```

## ๐Ÿš€ Key Innovations

### 1. WEB CTEs
Query HTTP APIs as SQL tables:
```sql
WITH WEB users AS (
    URL 'https://api.example.com/users'
    FORMAT JSON
    JSON_PATH 'users'
)
SELECT * FROM users WHERE active = true;
```

### 2. Smart Column Expansion
`\sE` on `SELECT *` discovers actual columns from query execution

### 3. Instant Cardinality
`\srD` on column name shows top 100 distinct values with counts

### 4. FIX Protocol Integration
Tag-based JSON syntax for FIX message analysis with group aggregation

## ๐Ÿ“Š Usage Patterns

**Typical Workflow**:
```
1. Write SQL in .sql buffer
2. \sx to execute (see results)
3. \sE to expand SELECT *
4. \srD to analyze column cardinality
5. Refine query based on insights
6. \sc to copy results (TSV to clipboard)
7. Paste into spreadsheet or docs
```

**Power User**:
- Chain CTEs to build complex analysis
- Reference previous query results
- Custom projections via Lua (planned)
- Multiple rendering styles (planned)

## ๐ŸŽฏ Success Metrics

**Developer Experience**:
- Query to insight: **<30 seconds**
- Common operations: **<3 keystrokes**
- Plugin startup: **<100ms**
- No context switching

**Stability**:
- Zero crashes in normal workflow
- Graceful error handling
- Fast feedback on all operations

## ๐Ÿ”ฎ Future Vision (6-12 months)

### Data Model Evolution
- Structured data storage (no buffer parsing)
- Multiple renderers (table/compact/summary)
- CTE composition (chain queries)
- Lua scripting for custom transforms

### Advanced Features
- Live queries with auto-refresh
- Visual query diff
- Collaborative CTE sharing
- Query history with undo/redo
- Sparklines and decorations
- Custom aggregations in Lua

### Extensibility
- User-supplied Lua transforms
- Custom renderer plugins
- Domain-specific functions
- Integration with external tools

## ๐Ÿ“ˆ Project Stats

- **Lines of Code**: ~50K (Rust + Lua)
- **Documentation**: ~20 active docs, ~193 archived
- **SQL Functions**: 100+
- **Test Coverage**: Integration + unit tests
- **Performance**: Adequate for <30K rows
- **Development Focus**: 80% plugin, 15% core, 5% TUI

## ๐Ÿค Contributing

1. Read [START_HERE.md](START_HERE.md)
2. Check [PRIORITIZED_TASKS.md](PRIORITIZED_TASKS.md) for P0/P1 items
3. Pick a "Quick Win" or P0 task
4. Focus on plugin improvements
5. Test in real workflow before PR

**Good First Issues**:
- P0-1: Fuzzy search strictness
- P0-2: FIX proxy documentation
- Quick wins: See PRIORITIZED_TASKS.md

## ๐Ÿ“ž Resources

- **Repository**: [github.com/TimelordUK/sql-cli](https://github.com/TimelordUK/sql-cli)
- **Documentation**: `/docs` directory
- **Examples**: `/examples` directory
- **Tests**: `/tests` directory

---

**TL;DR**: Fast SQL tool. Great Neovim plugin. Focus on developer experience. Plugin-first architecture. Data model evolution coming soon. ๐Ÿš€