pg_fake_sqlparser 0.63.0

SQL lexer and parser fork maintained for pg_fake
Documentation

pg_fake_sqlparser

A fork of Apache DataFusion sqlparser-rs, maintained for pg_fake. It carries parser and AST changes needed by the in-memory PostgreSQL test double. This is an independently maintained fork, not an official Apache release.

The published package is pg_fake_sqlparser; the Rust library name remains sqlparser. It parses SQL into an abstract syntax tree (AST). It does not execute SQL or validate database schemas.

Installation

[dependencies]
sqlparser = { package = "pg_fake_sqlparser", version = "0.63.0" }

Keep the dependency key sqlparser, including when using the fork's macros.

use sqlparser::dialect::PostgreSqlDialect;
use sqlparser::parser::Parser;

fn main() -> Result<(), sqlparser::parser::ParserError> {
    let statements = Parser::parse_sql(&PostgreSqlDialect {}, "SELECT 1")?;
    assert_eq!(statements.len(), 1);
    println!("{}", statements[0]);
    Ok(())
}

Features

  • std and recursive-protection are enabled by default.
  • visitor enables AST traversal and visitor derives.
  • derive-dialect enables the derive_dialect! macro for custom dialects.
  • serde enables AST serialization and deserialization.

For example, enable AST traversal and custom dialects with:

sqlparser = { package = "pg_fake_sqlparser", version = "0.63.0", features = ["visitor", "derive-dialect"] }

Parser and derive versions

pg_fake_sqlparser 0.63.0 is paired with pg_fake_sqlparser_derive 0.6.0. The parser pins that derive version exactly and enables it through the visitor or derive-dialect features. Most users should enable those features rather than depend directly on the derive crate.

The derive_dialect! macro reads the paired parser's dialect trait source. It supports the repository's derive/ layout and Cargo registry directories named pg_fake_sqlparser-0.63.0. Unversioned vendor directories are not supported by this lookup.

When preparing a new parser version, update derive/parser-version, release an appropriately versioned derive crate, and update the parser's exact derive dependency together. The version-pairing test checks that the recorded parser version matches the parser manifest. Fork release numbers and compatibility are managed independently of upstream.

Documentation and development

Run the parser and derive tests, formatting check, and lints from the repository root:

cargo test -p pg_fake_sqlparser -p pg_fake_sqlparser_derive --all-features
cargo fmt --all -- --check
cargo clippy --workspace --all-targets --all-features -- -D warnings

License and attribution

Licensed under Apache-2.0. Upstream attribution is retained in NOTICE.TXT and the source files. This fork includes modifications for pg_fake; upstream authorship is preserved.