Skip to content

Commit b23f2ab

Browse files
authored
Merge pull request #5 from fmguerreiro/chore/merge-upstream-main
chore: merge upstream apache/datafusion-sqlparser-rs main
2 parents c76e088 + 8aaef8d commit b23f2ab

64 files changed

Lines changed: 17013 additions & 2930 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AGENTS.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Extensible SQL Lexer and Parser for Rust Agents Guidelines
2+
3+
## General Agent Workflow
4+
1. You will write unit tests to ensure your code change is working as expected.
5+
2. You will run the commands in the Pre Commit Checks section below to ensure your change is ready for a pull request.
6+
3. When instructed to open a PR, you will follow the instructions in the Pull Request Guidelines section below.
7+
8+
## General Coding Guidelines
9+
1. Refrain from adding conditions on specific dialects, such as `dialect_is!(...)` or `dialect_of!(... | ...)`. Instead, define a new function in the `Dialect` trait that describes the condition, so that dialects can turn this condition on more easily.
10+
2. Make targeted code changes and refrain from refactoring, unless it's absolutely required.
11+
12+
## Unit Tests Guidelines
13+
- New unit tests should be added to the `tests` module in the corresponding dialect file (e.g., `tests/sqlparser_redshift.rs` for Redshift), and should be placed at the end of the file.
14+
- If the new functionality is gated using a dialect function, and the SQL is likely relevant in most dialects, tests should be placed under `tests/sqlparser_common.rs`.
15+
- When testing a multi-line SQL statement, use a raw string literal, i.e. `r#"..."#` to preserve formatting.
16+
- The parser builds an abstract syntax tree (AST) from the SQL statement and has functionality to display the tree as SQL. Use the following template for simple unit tests where you expect the SQL created from the AST to be the same as the input SQL:
17+
```rust
18+
<dialect>().verified_stmt(r#"..."#);
19+
```
20+
For example: `snowflake().verified_stmt(r#"SELECT * FROM my_table"#)`. Use `one_statement_parses_to` instead of `verified_stmt` when you expect the SQL created by the AST to differ than the input SQL. For example:
21+
```rust
22+
snowflake().one_statement_parses_to(
23+
"SELECT * FROM my_table t",
24+
"SELECT * FROM my_table AS t",
25+
)
26+
```
27+
28+
## Analyzing Parsing Issues
29+
You can try to simplify the SQL statement to identify the root cause of the parsing issue. This may involve removing certain clauses or components of the SQL statement to see if it can be parsed successfully. Additionally, you can compare the problematic SQL statement with similar statements that are parsed correctly to identify any differences that may be causing the issue.
30+
31+
## Pre Commit Checks
32+
Run the following commands before you commit to ensure the change will pass the CI process:
33+
```bash
34+
cargo test --all-features
35+
cargo fmt --all
36+
cargo clippy --all-targets --all-features -- -D warnings
37+
```
38+
39+
## Pull Request Guidelines
40+
1. PR title should follow this format: `<DIALECT>: <SHORT DESCRIPTION>`, For example, `Showflake: Add support for casting to VARIANT`.
41+
2. Make the PR comment short, provide an example of what was not working and a short description of the fix. Be succint.

Cargo.toml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
[package]
1919
name = "pgmold-sqlparser"
2020
description = "Fork of sqlparser with additional PostgreSQL features (PARTITION OF, SECURITY DEFINER/INVOKER, SET params)"
21-
version = "0.60.6"
21+
version = "0.60.7"
2222
authors = ["Filipe Guerreiro <filipe.m.guerreiro@gmail.com>"]
2323
homepage = "https://github.com/fmguerreiro/datafusion-sqlparser-rs"
2424
documentation = "https://docs.rs/pgmold-sqlparser/"
@@ -42,6 +42,7 @@ std = []
4242
recursive-protection = ["std", "recursive"]
4343
# Enable JSON output in the `cli` example:
4444
json_example = ["serde_json", "serde"]
45+
derive-dialect = ["sqlparser_derive"]
4546
visitor = ["sqlparser_derive"]
4647

4748
[dependencies]
@@ -54,13 +55,17 @@ serde = { version = "1.0", default-features = false, features = ["derive", "allo
5455
# of dev-dependencies because of
5556
# https://github.com/rust-lang/cargo/issues/1596
5657
serde_json = { version = "1.0", optional = true }
57-
sqlparser_derive = { version = "0.4.0", path = "derive", optional = true }
58+
sqlparser_derive = { version = "0.5.0", path = "derive", optional = true }
5859

5960
[dev-dependencies]
6061
simple_logger = "5.0"
6162
matches = "0.1"
6263
pretty_assertions = "1"
6364

65+
[[test]]
66+
name = "sqlparser_derive_dialect"
67+
required-features = ["derive-dialect"]
68+
6469
[package.metadata.docs.rs]
6570
# Document these features on docs.rs
66-
features = ["serde", "visitor"]
71+
features = ["serde", "visitor", "derive-dialect"]

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ $ cargo run --features json_example --example cli FILENAME.sql [--dialectname]
159159

160160
## Users
161161

162-
This parser is currently being used by the [DataFusion] query engine, [LocustDB],
163-
[Ballista], [GlueSQL], [Opteryx], [Polars], [PRQL], [Qrlew], [JumpWire], [ParadeDB], [CipherStash Proxy],
164-
and [GreptimeDB].
162+
This parser is currently being used by the [DataFusion] query engine,
163+
[LocustDB], [Ballista], [GlueSQL], [Opteryx], [Polars], [PRQL], [Qrlew],
164+
[JumpWire], [ParadeDB], [CipherStash Proxy], [Readyset] and [GreptimeDB].
165165

166166
If your project is using sqlparser-rs feel free to make a PR to add it
167167
to this list.
@@ -282,3 +282,4 @@ licensed as above, without any additional terms or conditions.
282282
[`GenericDialect`]: https://docs.rs/sqlparser/latest/sqlparser/dialect/struct.GenericDialect.html
283283
[CipherStash Proxy]: https://github.com/cipherstash/proxy
284284
[GreptimeDB]: https://github.com/GreptimeTeam/greptimedb
285+
[Readyset]: https://github.com/readysettech/readyset

changelog/0.61.0.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
20+
# sqlparser-rs 0.61.0 Changelog
21+
22+
This release consists of 66 commits from 22 contributors. See credits at the end of this changelog for more information.
23+
24+
**Performance related:**
25+
26+
- perf: remove unnecessary string clone in maybe_concat_string_literal [#2173](https://github.com/apache/datafusion-sqlparser-rs/pull/2173) (andygrove)
27+
- perf: optimize `make_word()` to avoid unnecessary allocations [#2176](https://github.com/apache/datafusion-sqlparser-rs/pull/2176) (andygrove)
28+
29+
**Fixed bugs:**
30+
31+
- fix: Set the current folder as a "primary" for the `find` command [#2120](https://github.com/apache/datafusion-sqlparser-rs/pull/2120) (martin-g)
32+
- fix: qualified column names with SQL keywords parse as identifiers [#2157](https://github.com/apache/datafusion-sqlparser-rs/pull/2157) (bombsimon)
33+
34+
**Other:**
35+
36+
- Fixing location for extrenal tables [#2108](https://github.com/apache/datafusion-sqlparser-rs/pull/2108) (romanoff)
37+
- Added support for `ALTER OPERATOR` syntax [#2114](https://github.com/apache/datafusion-sqlparser-rs/pull/2114) (LucaCappelletti94)
38+
- Oracle: Support for MERGE predicates [#2101](https://github.com/apache/datafusion-sqlparser-rs/pull/2101) (xitep)
39+
- [Oracle] Lower StringConcat precedence [#2115](https://github.com/apache/datafusion-sqlparser-rs/pull/2115) (xitep)
40+
- Added alter external table support for snowflake [#2122](https://github.com/apache/datafusion-sqlparser-rs/pull/2122) (romanoff)
41+
- MSSQL: Add support for parenthesized stored procedure name in EXEC [#2126](https://github.com/apache/datafusion-sqlparser-rs/pull/2126) (yoavcloud)
42+
- MSSQL: Parse IF/ELSE without semicolon delimiters [#2128](https://github.com/apache/datafusion-sqlparser-rs/pull/2128) (yoavcloud)
43+
- Extract source comments [#2107](https://github.com/apache/datafusion-sqlparser-rs/pull/2107) (xitep)
44+
- PostgreSQL: Support schema-qualified operator classes in CREATE INDEX [#2131](https://github.com/apache/datafusion-sqlparser-rs/pull/2131) (dddenis)
45+
- Oracle: Support for quote delimited strings [#2130](https://github.com/apache/datafusion-sqlparser-rs/pull/2130) (xitep)
46+
- Added support for `ALTER OPERATOR FAMILY` syntax [#2125](https://github.com/apache/datafusion-sqlparser-rs/pull/2125) (LucaCappelletti94)
47+
- PostgreSQL Tokenization: Fix unexpected characters after question mark being silently ignored [#2129](https://github.com/apache/datafusion-sqlparser-rs/pull/2129) (jnlt3)
48+
- Support parsing parenthesized wildcard `(*)` [#2123](https://github.com/apache/datafusion-sqlparser-rs/pull/2123) (romanoff)
49+
- Make benchmark statement valid [#2139](https://github.com/apache/datafusion-sqlparser-rs/pull/2139) (xitep)
50+
- Fix parse_identifiers not taking semicolons into account [#2137](https://github.com/apache/datafusion-sqlparser-rs/pull/2137) (jnlt3)
51+
- Add PostgreSQL PARTITION OF syntax support [#2127](https://github.com/apache/datafusion-sqlparser-rs/pull/2127) (fmguerreiro)
52+
- Databricks: Support Timetravel With "TIMESTAMP AS OF" [#2134](https://github.com/apache/datafusion-sqlparser-rs/pull/2134) (JamesVorder)
53+
- MySQL: Parse bitwise shift left/right operators [#2152](https://github.com/apache/datafusion-sqlparser-rs/pull/2152) (mvzink)
54+
- Redshift: Add support for optional JSON format in copy option [#2141](https://github.com/apache/datafusion-sqlparser-rs/pull/2141) (yoavcloud)
55+
- MySQL: Add missing support for TREE explain format [#2145](https://github.com/apache/datafusion-sqlparser-rs/pull/2145) (yoavcloud)
56+
- MySQL: Add support for && as boolean AND [#2144](https://github.com/apache/datafusion-sqlparser-rs/pull/2144) (yoavcloud)
57+
- PostgreSQL: ALTER USER password option [#2142](https://github.com/apache/datafusion-sqlparser-rs/pull/2142) (yoavcloud)
58+
- Key Value Options: add support for trailing semicolon [#2140](https://github.com/apache/datafusion-sqlparser-rs/pull/2140) (yoavcloud)
59+
- Added support for `ALTER OPERATOR CLASS` syntax [#2135](https://github.com/apache/datafusion-sqlparser-rs/pull/2135) (LucaCappelletti94)
60+
- Added missing `Copy` derives [#2158](https://github.com/apache/datafusion-sqlparser-rs/pull/2158) (LucaCappelletti94)
61+
- Tokenize empty line comments correctly [#2161](https://github.com/apache/datafusion-sqlparser-rs/pull/2161) (zyuiop)
62+
- Add support for DuckDB `LAMBDA` keyword syntax [#2149](https://github.com/apache/datafusion-sqlparser-rs/pull/2149) (lovasoa)
63+
- MySQL: Add support for casting using the BINARY keyword [#2146](https://github.com/apache/datafusion-sqlparser-rs/pull/2146) (yoavcloud)
64+
- Added missing `From` impls for `Statement` variants [#2160](https://github.com/apache/datafusion-sqlparser-rs/pull/2160) (LucaCappelletti94)
65+
- GenericDialect: support colon operator for JsonAccess [#2124](https://github.com/apache/datafusion-sqlparser-rs/pull/2124) (Samyak2)
66+
- Databricks: Support Timetravel With "VERSION AS OF" [#2155](https://github.com/apache/datafusion-sqlparser-rs/pull/2155) (JamesVorder)
67+
- Fixed truncate table if exists for snowflake [#2166](https://github.com/apache/datafusion-sqlparser-rs/pull/2166) (romanoff)
68+
- Refactor: replace some `dialect_of!` checks with `Dialect` trait methods [#2171](https://github.com/apache/datafusion-sqlparser-rs/pull/2171) (andygrove)
69+
- MySQL: Support `CAST(... AS ... ARRAY)` syntax [#2151](https://github.com/apache/datafusion-sqlparser-rs/pull/2151) (mvzink)
70+
- Snowflake: Support SAMPLE clause on subqueries [#2164](https://github.com/apache/datafusion-sqlparser-rs/pull/2164) (finchxxia)
71+
- refactor: use `to_ident()` instead of `clone().into_ident()` for borrowed Words [#2177](https://github.com/apache/datafusion-sqlparser-rs/pull/2177) (andygrove)
72+
- Refactor: replace more `dialect_of!` checks with `Dialect` trait methods [#2175](https://github.com/apache/datafusion-sqlparser-rs/pull/2175) (andygrove)
73+
- minor: reduce unnecessary string allocations [#2178](https://github.com/apache/datafusion-sqlparser-rs/pull/2178) (andygrove)
74+
- PostgreSQL: Support force row level security [#2169](https://github.com/apache/datafusion-sqlparser-rs/pull/2169) (isaacparker0)
75+
- PostgreSQL: Add support for `*` (descendant) option in TRUNCATE [#2181](https://github.com/apache/datafusion-sqlparser-rs/pull/2181) (mvzink)
76+
- Fix identifier parsing not breaking on the `|>` pipe operator [#2156](https://github.com/apache/datafusion-sqlparser-rs/pull/2156) (alexander-beedie)
77+
- [MySQL, Oracle] Parse optimizer hints [#2162](https://github.com/apache/datafusion-sqlparser-rs/pull/2162) (xitep)
78+
- Redshift: Support implicit string concatenation using newline [#2167](https://github.com/apache/datafusion-sqlparser-rs/pull/2167) (yoavcloud)
79+
- PostgreSQL: Fix REPLICA IDENTITY to use NOTHING [#2179](https://github.com/apache/datafusion-sqlparser-rs/pull/2179) (mvzink)
80+
- Add ENFORCED/NOT ENFORCED support for column-level CHECK constraints [#2180](https://github.com/apache/datafusion-sqlparser-rs/pull/2180) (mvzink)
81+
- Implement `core::error::Error` for `ParserError` and `TokenizerError` [#2189](https://github.com/apache/datafusion-sqlparser-rs/pull/2189) (LucaCappelletti94)
82+
- Moved more structs outside of Statement to facilitate reuse [#2188](https://github.com/apache/datafusion-sqlparser-rs/pull/2188) (LucaCappelletti94)
83+
- Fix parsing cast operator after parenthesized `DEFAULT` expression [#2168](https://github.com/apache/datafusion-sqlparser-rs/pull/2168) (isaacparker0)
84+
- Streamlined derivation of new `Dialect` objects [#2174](https://github.com/apache/datafusion-sqlparser-rs/pull/2174) (alexander-beedie)
85+
- MSSQL: Support standalone BEGIN...END blocks [#2186](https://github.com/apache/datafusion-sqlparser-rs/pull/2186) (guan404ming)
86+
- MySQL: Add support for `SELECT` modifiers [#2172](https://github.com/apache/datafusion-sqlparser-rs/pull/2172) (mvzink)
87+
- MySQL: Add support for DEFAULT CHARACTER SET in CREATE DATABASE [#2182](https://github.com/apache/datafusion-sqlparser-rs/pull/2182) (mvzink)
88+
- [Oracle] Support hierarchical queries [#2185](https://github.com/apache/datafusion-sqlparser-rs/pull/2185) (xitep)
89+
- MySQL: Allow optional constraint name after CONSTRAINT keyword [#2183](https://github.com/apache/datafusion-sqlparser-rs/pull/2183) (mvzink)
90+
- Added missing derives to dialect marker structs [#2191](https://github.com/apache/datafusion-sqlparser-rs/pull/2191) (LucaCappelletti94)
91+
- Fixed overflow error, recursion counter was not included for parenthesis [#2199](https://github.com/apache/datafusion-sqlparser-rs/pull/2199) (LucaCappelletti94)
92+
- Add support for C-style comments [#2034](https://github.com/apache/datafusion-sqlparser-rs/pull/2034) (altmannmarcelo)
93+
- PostgreSQL: Support PostgreSQL ANALYZE with optional table and column [#2187](https://github.com/apache/datafusion-sqlparser-rs/pull/2187) (guan404ming)
94+
- Add Tokenizer custom token mapper support [#2184](https://github.com/apache/datafusion-sqlparser-rs/pull/2184) (askalt)
95+
- Fix MAP literals parsing [#2205](https://github.com/apache/datafusion-sqlparser-rs/pull/2205) (Samyak2)
96+
97+
## Credits
98+
99+
Thank you to everyone who contributed to this release. Here is a breakdown of commits (PRs merged) per contributor.
100+
101+
```
102+
9 Luca Cappelletti
103+
9 Yoav Cohen
104+
8 Michael Victor Zink
105+
7 xitep
106+
6 Andy Grove
107+
4 Andriy Romanov
108+
2 Alexander Beedie
109+
2 Andrew Lamb
110+
2 Guan-Ming (Wesley) Chiu
111+
2 James Vorderbruggen
112+
2 Samyak Sarnayak
113+
2 isaacparker0
114+
2 jnlt3
115+
1 Albert Skalt
116+
1 Denis Goncharenko
117+
1 Filipe Guerreiro
118+
1 Louis Vialar
119+
1 Marcelo Altmann
120+
1 Martin Grigorov
121+
1 Ophir LOJKINE
122+
1 Simon Sawert
123+
1 finchxxia
124+
```
125+
126+
Thank you also to everyone who contributed in other ways such as filing issues, reviewing PRs, and providing feedback on this release.
127+

derive/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
[package]
1919
name = "sqlparser_derive"
2020
description = "Procedural (proc) macros for sqlparser"
21-
version = "0.4.0"
21+
version = "0.5.0"
2222
authors = ["sqlparser-rs authors"]
2323
homepage = "https://github.com/sqlparser-rs/sqlparser-rs"
2424
documentation = "https://docs.rs/sqlparser_derive/"
@@ -36,6 +36,6 @@ edition = "2021"
3636
proc-macro = true
3737

3838
[dependencies]
39-
syn = { version = "2.0", default-features = false, features = ["printing", "parsing", "derive", "proc-macro"] }
39+
syn = { version = "2.0", default-features = false, features = ["full", "printing", "parsing", "derive", "proc-macro", "clone-impls"] }
4040
proc-macro2 = "1.0"
4141
quote = "1.0"

0 commit comments

Comments
 (0)