Skip to content

Commit 9da62f6

Browse files
committed
README: update for recent improvements
Remove outdated bits that claim shoddy SQL support and code structure--we're much better on those fronts now! Also add a few paragraphs about the current state of SQL compliance, why it's hard to say anything detailed about SQL compliance, and what our long-term goals are.
1 parent 7a4eb50 commit 9da62f6

File tree

1 file changed

+55
-13
lines changed

1 file changed

+55
-13
lines changed

README.md

Lines changed: 55 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@
66
[![Coverage Status](https://coveralls.io/repos/github/andygrove/sqlparser-rs/badge.svg?branch=master)](https://coveralls.io/github/andygrove/sqlparser-rs?branch=master)
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 SQL that conforms with the [ANSI SQL:2011](https://jakewheat.github.io/sql-overview/sql-2011-foundation-grammar.html#_5_1_sql_terminal_character) standard but also making it easy to support custom dialects so that this crate can be used as a foundation for vendor-specific parsers.
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.
1013

11-
This parser is currently being used by the [DataFusion](https://github.com/andygrove/datafusion) query engine and [LocustDB](https://github.com/cswinter/LocustDB).
14+
This parser is currently being used by the [DataFusion] query engine and
15+
[LocustDB].
1216

1317
## Example
1418

15-
The current code is capable of parsing some trivial SELECT and CREATE TABLE statements.
19+
To parse a simple `SELECT` statement:
1620

1721
```rust
1822
let sql = "SELECT a, b, 123, myfunc(b) \
@@ -33,23 +37,61 @@ This outputs
3337
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 })]
3438
```
3539

40+
## SQL compliance
41+
42+
SQL was first standardized in 1987, and revisions of the standard have been
43+
published regularly since. Most revisions have added significant new features to
44+
the language, and as a result no database claims to support the full breadth of
45+
features. This parser currently supports most of the SQL-92 syntax, plus some
46+
syntax from newer versions that have been explicitly requested, plus some MSSQL-
47+
and PostgreSQL-specific syntax. Whenever possible, the [online SQL:2011
48+
grammar][sql-2011-grammar] is used to guide what syntax to accept. (We will
49+
happily accept changes that conform to the SQL:2016 syntax as well, but that
50+
edition's grammar is not yet available online.)
51+
52+
Unfortunately, stating anything more specific about compliance is difficult.
53+
There is no publicly available test suite that can assess compliance
54+
automatically, and doing so manually would strain the project's limited
55+
resources. Still, we are interested in eventually supporting the full SQL
56+
dialect, and pull requests that improve compliance will almost certainly be
57+
accepted.
58+
59+
If you are assessing whether this project will be suitable for your needs,
60+
you'll likely need to experimentally verify whether it supports the subset of
61+
SQL that you need. Please file issues about any unsupported queries that you
62+
discover. Doing so helps us prioritize support for the portions of the standard
63+
that are actually used.
64+
65+
### Supporting custom SQL dialects
66+
67+
This is a work in progress, but we have some notes on [writing a custom SQL
68+
parser](docs/custom_sql_parser.md).
69+
3670
## Design
3771

38-
This parser is implemented using the [Pratt Parser](https://tdop.github.io/) design, which is a top-down operator-precedence parser.
72+
This parser is implemented using the [Pratt Parser] design, which is a top-down
73+
operator-precedence parser.
3974

40-
I am a fan of this design pattern over parser generators for the following reasons:
75+
We are a fan of this design pattern over parser generators for the following
76+
reasons:
4177

42-
- Code is simple to write and can be concise and elegant (this is far from true for this current implementation unfortunately, but I hope to fix that using some macros)
78+
- Code is simple to write and can be concise and elegant
4379
- Performance is generally better than code generated by parser generators
4480
- Debugging is much easier with hand-written code
45-
- It is far easier to extend and make dialect-specific extensions compared to using a parser generator
46-
47-
## Supporting custom SQL dialects
48-
49-
This is a work in progress but I started some notes on [writing a custom SQL parser](docs/custom_sql_parser.md).
81+
- It is far easier to extend and make dialect-specific extensions
82+
compared to using a parser generator
5083

5184
## Contributing
5285

53-
Contributors are welcome! Please see the [current issues](https://github.com/andygrove/sqlparser-rs/issues) and feel free to file more!
86+
Contributors are welcome! Please see the [current issues] and feel free to file
87+
more!
88+
89+
Please run [`cargo fmt`] to ensure the code is properly formatted.
5490

55-
Please run [cargo fmt](https://github.com/rust-lang/rustfmt#on-the-stable-toolchain) to ensure the code is properly formatted.
91+
[`cargo fmt`]: https://github.com/rust-lang/rustfmt#on-the-stable-toolchain
92+
[current issues]: https://github.com/andygrove/sqlparser-rs/issues
93+
[DataFusion]: https://github.com/apache/arrow/tree/master/rust/datafusion
94+
[LocustDB]: https://github.com/cswinter/LocustDB
95+
[Pratt Parser]: https://tdop.github.io/
96+
[sql-2011-grammar]: https://jakewheat.github.io/sql-overview/sql-2011-foundation-grammar.html
97+
[sql-standard]: https://en.wikipedia.org/wiki/ISO/IEC_9075

0 commit comments

Comments
 (0)