// the find
apache/datafusion-sqlparser-rs
Extensible SQL Lexer and Parser for Rust
A hand-written Pratt parser + recursive descent SQL parser for Rust, used as the foundation under DataFusion, Polars, Readyset, and about a dozen other projects. It targets syntax only — no semantic analysis — and supports a wide range of dialects via a trait-based extension system. If you're building a query engine or SQL analysis tool in Rust, this is the obvious starting point.
1. Genuinely good dialect abstraction: each dialect is a trait impl that can override specific parsing behaviors, so you can add vendor-specific syntax without forking the core. 2. Round-trip fidelity is a first-class concern — the AST can be serialized back to SQL with normalized whitespace, which matters for query rewriters and proxies. 3. Production-proven under heavy load in DataFusion, Polars, and Readyset, so the parser itself is not a gamble. 4. Fuzz testing infrastructure is already wired up, which catches the kind of edge cases that matter when you're parsing untrusted SQL.
1. Source span tracking (the `Spanned` trait) is explicitly marked work-in-progress and many nodes return missing or inaccurate spans — a serious gap if you need error messages that point users at the right token. 2. No semantic layer at all by design, which is honest but means you get no help with name resolution, type checking, or dialect-specific validity — you're on your own for everything past the AST. 3. The maintainers are upfront that new features won't get implemented by them; if a dialect quirk you need isn't covered, you're writing it yourself. 4. The AST is verbose and the `to_string` round-trip strips comments entirely, which is a problem for tools that need to preserve or transform annotated SQL.