A high-performance SQLite3 parser implemented in Rust using the Logos lexer.
This project implements a parser for SQLite3 SQL statements, focusing on high performance and memory efficiency. It uses the Logos lexer for tokenization and implements a recursive descent parser to produce an abstract syntax tree (AST).
- Fast lexical analysis with Logos
- Comprehensive SQLite3 syntax support
- Memory-efficient parsing
- Clear and well-structured AST
- Does not support UNION
- Does not support INTERSECT
- Does not support EXCEPT
- Does not support CASE/WHEN, IF
use sqlite3_parser_logos::parse_statement;
fn main() {
let sql = "SELECT id, name FROM users WHERE age > 18;";
match parse_statement(sql) {
Ok(stmt) => println!("Successfully parsed: {:?}", stmt),
Err(err) => println!("Parse error: {}", err),
}
}
The project includes benchmarks to compare performance against other SQL parsers.
# Run all benchmarks
cargo bench
# Analyze and display results in a table
cargo run --bin analyze_results
- Query Complexity Benchmarks: Tests parsing performance on queries of increasing complexity
- Batch Processing Benchmarks: Measures throughput when parsing multiple queries
- Repeated Parsing Benchmarks: Tests performance when parsing the same query repeatedly
The benchmarks compare this parser with sqlparser-rs, another popular SQL parser in Rust.
This project is licensed under the MIT License - see the LICENSE file for details.