Skip to content

Commit 751046d

Browse files
authored
Improve Readme (#774)
1 parent dec3c2b commit 751046d

File tree

2 files changed

+47
-27
lines changed

2 files changed

+47
-27
lines changed

README.md

Lines changed: 44 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,10 @@
66
[![Coverage Status](https://coveralls.io/repos/github/sqlparser-rs/sqlparser-rs/badge.svg?branch=main)](https://coveralls.io/github/sqlparser-rs/sqlparser-rs?branch=main)
77
[![Gitter Chat](https://badges.gitter.im/sqlparser-rs/community.svg)](https://gitter.im/sqlparser-rs/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
88

9-
The goal of this project is to build a SQL lexer and parser capable of parsing
10-
SQL that conforms with the [ANSI/ISO SQL standard][sql-standard] while also
11-
making it easy to support custom dialects so that this crate can be used as a
12-
foundation for vendor-specific parsers.
13-
14-
This parser is currently being used by the [DataFusion] query engine,
15-
[LocustDB], [Ballista] and [GlueSQL].
16-
17-
This crate provides only a syntax parser, and tries to avoid applying
18-
any SQL semantics, and accepts queries that specific databases would
19-
reject, even when using that Database's specific `Dialect`. For
20-
example, `CREATE TABLE(x int, x int)` is accepted by this crate, even
21-
though most SQL engines will reject this statement due to the repeated
22-
column name `x`.
23-
24-
This crate avoids semantic analysis because it varies drastically
25-
between dialects and implementations. If you want to do semantic
26-
analysis, feel free to use this project as a base
9+
This crate contains a lexer and parser for SQL that conforms with the
10+
[ANSI/ISO SQL standard][sql-standard] and other dialects. This crate
11+
is used as a foundation for SQL query engines, vendor-specific
12+
parsers, and various SQL analysis.
2713

2814
## Example
2915

@@ -51,11 +37,27 @@ This outputs
5137
AST: [Query(Query { ctes: [], body: Select(Select { distinct: false, projection: [UnnamedExpr(Identifier("a")), UnnamedExpr(Identifier("b")), UnnamedExpr(Value(Long(123))), UnnamedExpr(Function(Function { name: ObjectName(["myfunc"]), args: [Identifier("b")], over: None, distinct: false }))], from: [TableWithJoins { relation: Table { name: ObjectName(["table_1"]), alias: None, args: [], with_hints: [] }, joins: [] }], selection: Some(BinaryOp { left: BinaryOp { left: Identifier("a"), op: Gt, right: Identifier("b") }, op: And, right: BinaryOp { left: Identifier("b"), op: Lt, right: Value(Long(100)) } }), group_by: [], having: None }), order_by: [OrderByExpr { expr: Identifier("a"), asc: Some(false) }, OrderByExpr { expr: Identifier("b"), asc: None }], limit: None, offset: None, fetch: None })]
5238
```
5339

54-
## Command line
55-
To parse a file and dump the results as JSON:
56-
```
57-
$ cargo run --features json_example --example cli FILENAME.sql [--dialectname]
58-
```
40+
41+
## Features
42+
43+
The following optional [crate features](https://doc.rust-lang.org/cargo/reference/features.html) are available:
44+
45+
* `serde`: Adds [Serde](https://serde.rs/) support by implementing `Serialize` and `Deserialize` for all AST nodes.
46+
* `visitor`: Adds a `Visitor` capable of recursively walking the AST tree.
47+
48+
49+
## Syntax vs Semantics
50+
51+
This crate provides only a syntax parser, and tries to avoid applying
52+
any SQL semantics, and accepts queries that specific databases would
53+
reject, even when using that Database's specific `Dialect`. For
54+
example, `CREATE TABLE(x int, x int)` is accepted by this crate, even
55+
though most SQL engines will reject this statement due to the repeated
56+
column name `x`.
57+
58+
This crate avoids semantic analysis because it varies drastically
59+
between dialects and implementations. If you want to do semantic
60+
analysis, feel free to use this project as a base.
5961

6062
## SQL compliance
6163

@@ -81,10 +83,21 @@ that are actually used. Note that if you urgently need support for a feature,
8183
you will likely need to write the implementation yourself. See the
8284
[Contributing](#Contributing) section for details.
8385

84-
### Supporting custom SQL dialects
86+
## Command line
87+
88+
This crate contains a CLI program that can parse a file and dump the results as JSON:
89+
```
90+
$ cargo run --features json_example --example cli FILENAME.sql [--dialectname]
91+
```
92+
93+
## Users
94+
95+
This parser is currently being used by the [DataFusion] query engine,
96+
[LocustDB], [Ballista] and [GlueSQL].
97+
98+
If your project is using sqlparser-rs feel free to make a PR to add it
99+
to this list.
85100

86-
This is a work in progress, but we have some notes on [writing a custom SQL
87-
parser](docs/custom_sql_parser.md).
88101

89102
## Design
90103

@@ -103,6 +116,11 @@ reasons:
103116
- It is far easier to extend and make dialect-specific extensions
104117
compared to using a parser generator
105118

119+
### Supporting custom SQL dialects
120+
121+
This is a work in progress, but we have some notes on [writing a custom SQL
122+
parser](docs/custom_sql_parser.md).
123+
106124
## Contributing
107125

108126
Contributions are highly encouraged! However, the bandwidth we have to

src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
//! SQL Parser for Rust
1414
//!
1515
//! This crate provides an ANSI:SQL 2011 lexer and parser that can parse SQL
16-
//! into an Abstract Syntax Tree (AST).
16+
//! into an Abstract Syntax Tree (AST). See the [sqlparser crates.io page]
17+
//! for more information.
1718
//!
1819
//! See [`Parser::parse_sql`](crate::parser::Parser::parse_sql) and
1920
//! [`Parser::new`](crate::parser::Parser::new) for the Parsing API
@@ -36,6 +37,7 @@
3637
//!
3738
//! println!("AST: {:?}", ast);
3839
//! ```
40+
//! [sqlparser crates.io page]: https://crates.io/crates/sqlparser
3941
4042
#![cfg_attr(not(feature = "std"), no_std)]
4143
#![allow(clippy::upper_case_acronyms)]

0 commit comments

Comments
 (0)