Datafusion-sqlparser-rs is an extensible SQL lexer and parser for Rust that conforms to the ANSI/ISO SQL standard and supports multiple SQL dialects.
The tool solves the problem of parsing SQL text into an abstract syntax tree for use in query engines, vendor-specific parsers, and SQL analysis tools. It implements a syntax-focused parser that deliberately avoids semantic analysis, accepting queries that specific databases might reject. This design choice allows the parser to remain dialect-agnostic and serve as a foundation that downstream tools can build semantic validation upon. The parser preserves the ability to round-trip SQL back to its original form, with only comments, whitespace, and keyword capitalization potentially differing from the input.
The project suits teams building SQL tooling, query engines, or analysis systems in Rust that need a reliable foundation for parsing multiple SQL dialects without being locked into a single database's semantic rules. It is particularly valuable for tools that manipulate or analyze SQL text and need to recover the original query structure. The crate offers optional features including Serde support for serialization, a visitor pattern for AST traversal, and stack overflow protection via recursive-protection enabled by default.
Development activity shows consistent engagement with dialect support expansion and incremental improvements to the AST representation. The project maintains an active backlog of work-in-progress features, particularly around source location tracking for diagnostics tooling, with contributors encouraged to submit improvements. The codebase demonstrates attention to correctness in distinguishing different SQL syntaxes within the AST, with maintainers welcoming pull requests to resolve cases where semantically different SQL statements map to identical AST nodes.