Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2f12821
Add Phase 1 SQL expression enhancements to VM
jgarzik Jan 9, 2026
300cf81
Add Phase 2 set operations (UNION, INTERSECT, EXCEPT) to VM
jgarzik Jan 9, 2026
0019fb3
Add Phase 3 outer joins (LEFT, RIGHT, FULL) to VM
jgarzik Jan 9, 2026
b669392
Add Phase 4A-4D memory optimization foundation for subqueries
jgarzik Jan 9, 2026
5fffca8
Add Phase 4E-4F: JOIN optimization and subquery support
jgarzik Jan 9, 2026
8e62b5d
Implement Phase 4F subquery support with compile-time execution
jgarzik Jan 9, 2026
70a1c9f
Consolidate test data into static CSV fixtures
jgarzik Jan 9, 2026
94ed072
Remove duplicate file getter functions from test modules
jgarzik Jan 9, 2026
8b77c5d
Complete VM execution engine migration and cleanup
jgarzik Jan 9, 2026
b60828d
Implement Phase 4B correlated subquery support
jgarzik Jan 9, 2026
773c733
Implement Phase 5: Complete DML support with INSERT...SELECT
jgarzik Jan 9, 2026
1a550a8
Implement Phase 7: Advanced expressions with math, string, date funct…
jgarzik Jan 9, 2026
42f4a9c
Implement Phase 8: Window functions with ROW_NUMBER, RANK, LAG/LEAD, …
jgarzik Jan 9, 2026
bfb4a7c
Implement Phase 10: DDL enhancements with DROP TABLE, ALTER TABLE, TR…
jgarzik Jan 9, 2026
8ab043d
remove todo (accidentally committed)
jgarzik Jan 9, 2026
7ce0d88
Cargo.toml: use LTO for release builds
jgarzik Jan 9, 2026
bd4553f
cargo fmt
jgarzik Jan 9, 2026
0fe0a77
CLAUDE.md
jgarzik Jan 9, 2026
d43ebe7
Refactor compiler.rs into smaller modules
jgarzik Jan 9, 2026
9bbed2a
Refactor compile_function() into focused helper functions
jgarzik Jan 9, 2026
f6a1839
Refactor compiler modules: add helpers, eliminate redundancies
jgarzik Jan 10, 2026
4235f7c
Unify instruction emission across all compiler modules
jgarzik Jan 10, 2026
d21d4ac
Add named constants for aggregate function types
jgarzik Jan 10, 2026
b58f361
Unify condition compilation with shared helpers
jgarzik Jan 10, 2026
8e8e6ed
Unify projection resolution with shared helpers
jgarzik Jan 10, 2026
0d6c96d
Use Rc<str> for instruction p4/comment to eliminate cloning overhead
jgarzik Jan 10, 2026
e5d62cd
Rewrite SQL reference to terse reference style
jgarzik Jan 10, 2026
5565c2a
Add tsq binary and multi-table aggregate support
jgarzik Jan 10, 2026
da51405
Reduce vector allocations in CSV/delim file loading
jgarzik Jan 10, 2026
72b66c2
Add mmap storage backend with read-ahead optimization
jgarzik Jan 10, 2026
83f1f96
Add capacity hints for collection pre-allocation
jgarzik Jan 10, 2026
6029acd
Refresh documentation for accuracy and clarity
jgarzik Jan 10, 2026
2beb552
Add tests for table definition modes and fix REPL multiline input
jgarzik Jan 10, 2026
369ff02
Add atomic file writes and fix output delimiter consistency
jgarzik Jan 10, 2026
cdd1168
Update dependency versions and fix deprecation warnings
jgarzik Jan 10, 2026
6a51713
Eliminate thiserror and rand dependencies
jgarzik Jan 10, 2026
b9a38f3
Bump version to 0.8.0 and improve crates.io metadata
jgarzik Jan 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Build and Test Commands

```bash
# Build the project
cargo build

# Run all tests
cargo test

# Run a specific test module
cargo test --test mod basic # Basic end-to-end tests
cargo test --test mod comparison # Comparison operator tests
cargo test --test mod join # JOIN tests
cargo test --test mod aggregate # Aggregate function tests

# Run a single test by name
cargo test test_name_here

# Run with verbose output
cargo test -- --nocapture

# Run the CLI directly
cargo run -- -s "SELECT * FROM data" data.csv

# Run in interactive REPL mode
cargo run -- --interactive data.csv
```

## Architecture Overview

Sqawk is an SQL-based CLI tool for processing delimiter-separated files (CSV, TSV, etc.). It loads files into in-memory tables, executes SQL queries, and optionally writes results back.

### Core Components

- **`main.rs`**: Entry point orchestrating the pipeline: CLI parsing → file loading → SQL execution → output → optional writeback
- **`database.rs`**: Central store for in-memory tables, manages table definitions and schemas
- **`table.rs`**: In-memory table representation with columns, rows, and projection capabilities
- **`sql_executor.rs`**: SQL parsing (via `sqlparser` crate) and execution against in-memory tables

### SQL Execution (VM-based)

SQL execution uses a bytecode VM inspired by SQLite's architecture:
1. SQL is parsed via the `sqlparser` crate
2. The AST is compiled to bytecode (`src/vm/compiler.rs`)
3. The VM engine executes the bytecode (`src/vm/engine.rs`)

### VM Module (`src/vm/`)

- `bytecode.rs`: Defines bytecode instruction set
- `compiler.rs`: Compiles SQL AST to bytecode
- `engine.rs`: Executes bytecode instructions

### File Handling

- **`file_handler.rs`**: Manages loading files into database tables
- **`csv_handler.rs`**: Standard CSV file parsing (comma-separated)
- **`delim_handler.rs`**: Custom delimiter support via `-F` flag (TSV, colon-separated, etc.)

### SQL Features

- `aggregate.rs`: COUNT, SUM, AVG, MIN, MAX functions
- `join.rs`: Cross join and INNER JOIN implementations
- `string_functions.rs`: UPPER, LOWER, TRIM, SUBSTR, REPLACE

### Safe Writeback Model

By default, all modifications remain in memory only. The `--write` flag must be explicitly provided to save changes back to source files. Only tables modified by INSERT/UPDATE/DELETE are written.

## Test Organization

Tests are in `tests/` organized by functionality:
- `basic/`, `comparison/`, `join/`, `join_on/`, `order_by/`, `update/`
- `aggregate/`, `alias/`, `distinct/`, `group_by/`, `limit_offset/`
- `delimiter/`, `csv_handler/`, `string_functions/`, `repl/`
- `helpers/`: Test utilities
- `common.rs`: Shared test helpers including REPL script runner

Tests use `assert_cmd` for CLI testing and `tempfile` for temporary test data.
Loading
Loading