Skip to content

Commit 83bb534

Browse files
committed
Merge branch 'main' of ssh://github.com/apache/datafusion-sqlparser-rs into ash/merge-upstream
2 parents ba34f62 + 703ba2c commit 83bb534

Some content is hidden

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

45 files changed

+6335
-1110
lines changed

.github/workflows/rust.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ name: Rust
1919

2020
on: [push, pull_request]
2121

22+
permissions:
23+
contents: read
24+
2225
jobs:
2326

2427
codestyle:
@@ -85,11 +88,8 @@ jobs:
8588
uses: ./.github/actions/setup-builder
8689
with:
8790
rust-version: ${{ matrix.rust }}
91+
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
8892
- name: Install Tarpaulin
89-
uses: actions-rs/install@v0.1
90-
with:
91-
crate: cargo-tarpaulin
92-
version: 0.14.2
93-
use-tool-cache: true
93+
run: cargo install cargo-tarpaulin
9494
- name: Test
9595
run: cargo test --all-features

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ technically be breaking and thus will result in a `0.(N+1)` version.
2828

2929

3030
- Unreleased: Check https://github.com/sqlparser-rs/sqlparser-rs/commits/main for undocumented changes.
31+
- `0.56.0`: [changelog/0.56.0.md](changelog/0.56.0.md)
3132
- `0.55.0`: [changelog/0.55.0.md](changelog/0.55.0.md)
3233
- `0.54.0`: [changelog/0.54.0.md](changelog/0.54.0.md)
3334
- `0.53.0`: [changelog/0.53.0.md](changelog/0.53.0.md)

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
[package]
1919
name = "sqlparser"
2020
description = "Extensible SQL Lexer and Parser with support for ANSI SQL:2011"
21-
version = "0.55.0"
21+
version = "0.56.0"
2222
authors = ["Apache DataFusion <dev@datafusion.apache.org>"]
2323
homepage = "https://github.com/apache/datafusion-sqlparser-rs"
2424
documentation = "https://docs.rs/sqlparser/"

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,14 @@ keywords, the following should hold true for all SQL:
8989

9090
```rust
9191
// Parse SQL
92+
let sql = "SELECT 'hello'";
9293
let ast = Parser::parse_sql(&GenericDialect, sql).unwrap();
9394

9495
// The original SQL text can be generated from the AST
9596
assert_eq!(ast[0].to_string(), sql);
97+
98+
// The SQL can also be pretty-printed with newlines and indentation
99+
assert_eq!(format!("{:#}", ast[0]), "SELECT\n 'hello'");
96100
```
97101

98102
There are still some cases in this crate where different SQL with seemingly

changelog/0.56.0.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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.56.0 Changelog
21+
22+
This release consists of 48 commits from 19 contributors. See credits at the end of this changelog for more information.
23+
24+
**Other:**
25+
26+
- Ignore escaped LIKE wildcards in MySQL [#1735](https://github.com/apache/datafusion-sqlparser-rs/pull/1735) (mvzink)
27+
- Parse SET NAMES syntax in Postgres [#1752](https://github.com/apache/datafusion-sqlparser-rs/pull/1752) (mvzink)
28+
- re-add support for nested comments in mssql [#1754](https://github.com/apache/datafusion-sqlparser-rs/pull/1754) (lovasoa)
29+
- Extend support for INDEX parsing [#1707](https://github.com/apache/datafusion-sqlparser-rs/pull/1707) (LucaCappelletti94)
30+
- Parse MySQL `ALTER TABLE DROP FOREIGN KEY` syntax [#1762](https://github.com/apache/datafusion-sqlparser-rs/pull/1762) (mvzink)
31+
- add support for `with` clauses (CTEs) in `delete` statements [#1764](https://github.com/apache/datafusion-sqlparser-rs/pull/1764) (lovasoa)
32+
- SET with a list of comma separated assignments [#1757](https://github.com/apache/datafusion-sqlparser-rs/pull/1757) (MohamedAbdeen21)
33+
- Preserve MySQL-style `LIMIT <offset>, <limit>` syntax [#1765](https://github.com/apache/datafusion-sqlparser-rs/pull/1765) (mvzink)
34+
- Add support for `DROP MATERIALIZED VIEW` [#1743](https://github.com/apache/datafusion-sqlparser-rs/pull/1743) (iffyio)
35+
- Add `CASE` and `IF` statement support [#1741](https://github.com/apache/datafusion-sqlparser-rs/pull/1741) (iffyio)
36+
- BigQuery: Add support for `CREATE SCHEMA` options [#1742](https://github.com/apache/datafusion-sqlparser-rs/pull/1742) (iffyio)
37+
- Snowflake: Support dollar quoted comments [#1755](https://github.com/apache/datafusion-sqlparser-rs/pull/1755)
38+
- Add LOCK operation for ALTER TABLE [#1768](https://github.com/apache/datafusion-sqlparser-rs/pull/1768) (MohamedAbdeen21)
39+
- Add support for `RAISE` statement [#1766](https://github.com/apache/datafusion-sqlparser-rs/pull/1766) (iffyio)
40+
- Add GLOBAL context/modifier to SET statements [#1767](https://github.com/apache/datafusion-sqlparser-rs/pull/1767) (MohamedAbdeen21)
41+
- Parse `SUBSTR` as alias for `SUBSTRING` [#1769](https://github.com/apache/datafusion-sqlparser-rs/pull/1769) (mvzink)
42+
- SET statements: scope modifier for multiple assignments [#1772](https://github.com/apache/datafusion-sqlparser-rs/pull/1772) (MohamedAbdeen21)
43+
- Support qualified column names in `MATCH AGAINST` clause [#1774](https://github.com/apache/datafusion-sqlparser-rs/pull/1774) (tomershaniii)
44+
- Mysql: Add support for := operator [#1779](https://github.com/apache/datafusion-sqlparser-rs/pull/1779) (barsela1)
45+
- Add cipherstash-proxy to list of users in README.md [#1782](https://github.com/apache/datafusion-sqlparser-rs/pull/1782) (coderdan)
46+
- Fix typos [#1785](https://github.com/apache/datafusion-sqlparser-rs/pull/1785) (jayvdb)
47+
- Add support for Databricks TIMESTAMP_NTZ. [#1781](https://github.com/apache/datafusion-sqlparser-rs/pull/1781) (romanb)
48+
- Enable double-dot-notation for mssql. [#1787](https://github.com/apache/datafusion-sqlparser-rs/pull/1787) (romanb)
49+
- Fix: Snowflake ALTER SESSION cannot be followed by other statements. [#1786](https://github.com/apache/datafusion-sqlparser-rs/pull/1786) (romanb)
50+
- Add GreptimeDB to the "Users" in README [#1788](https://github.com/apache/datafusion-sqlparser-rs/pull/1788) (MichaelScofield)
51+
- Extend snowflake grant options support [#1794](https://github.com/apache/datafusion-sqlparser-rs/pull/1794) (yoavcloud)
52+
- Fix clippy lint on rust 1.86 [#1796](https://github.com/apache/datafusion-sqlparser-rs/pull/1796) (iffyio)
53+
- Allow single quotes in EXTRACT() for Redshift. [#1795](https://github.com/apache/datafusion-sqlparser-rs/pull/1795) (romanb)
54+
- MSSQL: Add support for functionality `MERGE` output clause [#1790](https://github.com/apache/datafusion-sqlparser-rs/pull/1790) (dilovancelik)
55+
- Support additional DuckDB integer types such as HUGEINT, UHUGEINT, etc [#1797](https://github.com/apache/datafusion-sqlparser-rs/pull/1797) (alexander-beedie)
56+
- Add support for MSSQL IF/ELSE statements. [#1791](https://github.com/apache/datafusion-sqlparser-rs/pull/1791) (romanb)
57+
- Allow literal backslash escapes for string literals in Redshift dialect. [#1801](https://github.com/apache/datafusion-sqlparser-rs/pull/1801) (romanb)
58+
- Add support for MySQL's STRAIGHT_JOIN join operator. [#1802](https://github.com/apache/datafusion-sqlparser-rs/pull/1802) (romanb)
59+
- Snowflake COPY INTO target columns, select items and optional alias [#1805](https://github.com/apache/datafusion-sqlparser-rs/pull/1805) (yoavcloud)
60+
- Fix tokenization of qualified identifiers with numeric prefix. [#1803](https://github.com/apache/datafusion-sqlparser-rs/pull/1803) (romanb)
61+
- Add support for `INHERITS` option in `CREATE TABLE` statement [#1806](https://github.com/apache/datafusion-sqlparser-rs/pull/1806) (LucaCappelletti94)
62+
- Add `DROP TRIGGER` support for SQL Server [#1813](https://github.com/apache/datafusion-sqlparser-rs/pull/1813) (aharpervc)
63+
- Snowflake: support nested join without parentheses [#1799](https://github.com/apache/datafusion-sqlparser-rs/pull/1799) (barsela1)
64+
- Add support for parenthesized subquery as `IN` predicate [#1793](https://github.com/apache/datafusion-sqlparser-rs/pull/1793) (adamchainz)
65+
- Fix `STRAIGHT_JOIN` constraint when table alias is absent [#1812](https://github.com/apache/datafusion-sqlparser-rs/pull/1812) (killertux)
66+
- Add support for `PRINT` statement for SQL Server [#1811](https://github.com/apache/datafusion-sqlparser-rs/pull/1811) (aharpervc)
67+
- enable `supports_filter_during_aggregation` for Generic dialect [#1815](https://github.com/apache/datafusion-sqlparser-rs/pull/1815) (goldmedal)
68+
- Add support for `XMLTABLE` [#1817](https://github.com/apache/datafusion-sqlparser-rs/pull/1817) (lovasoa)
69+
- Add `CREATE FUNCTION` support for SQL Server [#1808](https://github.com/apache/datafusion-sqlparser-rs/pull/1808) (aharpervc)
70+
- Add `OR ALTER` support for `CREATE VIEW` [#1818](https://github.com/apache/datafusion-sqlparser-rs/pull/1818) (aharpervc)
71+
- Add `DECLARE ... CURSOR FOR` support for SQL Server [#1821](https://github.com/apache/datafusion-sqlparser-rs/pull/1821) (aharpervc)
72+
- Handle missing login in changelog generate script [#1823](https://github.com/apache/datafusion-sqlparser-rs/pull/1823) (iffyio)
73+
- Snowflake: Add support for `CONNECT_BY_ROOT` [#1780](https://github.com/apache/datafusion-sqlparser-rs/pull/1780) (tomershaniii)
74+
75+
## Credits
76+
77+
Thank you to everyone who contributed to this release. Here is a breakdown of commits (PRs merged) per contributor.
78+
79+
```
80+
8 Roman Borschel
81+
6 Ifeanyi Ubah
82+
5 Andrew Harper
83+
5 Michael Victor Zink
84+
4 Mohamed Abdeen
85+
3 Ophir LOJKINE
86+
2 Luca Cappelletti
87+
2 Yoav Cohen
88+
2 bar sela
89+
2 tomershaniii
90+
1 Adam Johnson
91+
1 Aleksei Piianin
92+
1 Alexander Beedie
93+
1 Bruno Clemente
94+
1 Dan Draper
95+
1 DilovanCelik
96+
1 Jax Liu
97+
1 John Vandenberg
98+
1 LFC
99+
```
100+
101+
Thank you also to everyone who contributed in other ways such as filing issues, reviewing PRs, and providing feedback on this release.
102+

dev/release/generate-changelog.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ def print_pulls(repo_name, title, pulls):
2828
print()
2929
for (pull, commit) in pulls:
3030
url = "https://github.com/{}/pull/{}".format(repo_name, pull.number)
31-
print("- {} [#{}]({}) ({})".format(pull.title, pull.number, url, commit.author.login))
31+
author = f"({commit.author.login})" if commit.author else ''
32+
print("- {} [#{}]({}) {}".format(pull.title, pull.number, url, author))
3233
print()
3334

3435

@@ -161,4 +162,4 @@ def cli(args=None):
161162
generate_changelog(repo, project, args.tag1, args.tag2, args.version)
162163

163164
if __name__ == "__main__":
164-
cli()
165+
cli()

sqlparser_bench/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ edition = "2018"
2626
sqlparser = { path = "../" }
2727

2828
[dev-dependencies]
29-
criterion = "0.5"
29+
criterion = "0.6"
3030

3131
[[bench]]
3232
name = "sqlparser_bench"

sqlparser_bench/benches/sqlparser_bench.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ fn basic_queries(c: &mut Criterion) {
6868
};
6969

7070
group.bench_function("parse_large_statement", |b| {
71-
b.iter(|| Parser::parse_sql(&dialect, criterion::black_box(large_statement.as_str())));
71+
b.iter(|| Parser::parse_sql(&dialect, std::hint::black_box(large_statement.as_str())));
7272
});
7373

7474
let large_statement = Parser::parse_sql(&dialect, large_statement.as_str())

src/ast/data_type.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,17 @@ pub enum DataType {
4848
/// Table type in [PostgreSQL], e.g. CREATE FUNCTION RETURNS TABLE(...).
4949
///
5050
/// [PostgreSQL]: https://www.postgresql.org/docs/15/sql-createfunction.html
51-
Table(Vec<ColumnDef>),
51+
/// [MsSQL]: https://learn.microsoft.com/en-us/sql/t-sql/statements/create-function-transact-sql?view=sql-server-ver16#c-create-a-multi-statement-table-valued-function
52+
Table(Option<Vec<ColumnDef>>),
53+
/// Table type with a name, e.g. CREATE FUNCTION RETURNS @result TABLE(...).
54+
///
55+
/// [MsSQl]: https://learn.microsoft.com/en-us/sql/t-sql/statements/create-function-transact-sql?view=sql-server-ver16#table
56+
NamedTable {
57+
/// Table name.
58+
name: ObjectName,
59+
/// Table columns.
60+
columns: Vec<ColumnDef>,
61+
},
5262
/// Fixed-length character type, e.g. CHARACTER(10).
5363
Character(Option<CharacterLength>),
5464
/// Fixed-length char type, e.g. CHAR(10).
@@ -716,7 +726,17 @@ impl fmt::Display for DataType {
716726
DataType::Unspecified => Ok(()),
717727
DataType::Trigger => write!(f, "TRIGGER"),
718728
DataType::AnyType => write!(f, "ANY TYPE"),
719-
DataType::Table(fields) => write!(f, "TABLE({})", display_comma_separated(fields)),
729+
DataType::Table(fields) => match fields {
730+
Some(fields) => {
731+
write!(f, "TABLE({})", display_comma_separated(fields))
732+
}
733+
None => {
734+
write!(f, "TABLE")
735+
}
736+
},
737+
DataType::NamedTable { name, columns } => {
738+
write!(f, "{} TABLE ({})", name, display_comma_separated(columns))
739+
}
720740
DataType::GeometricType(kind) => write!(f, "{}", kind),
721741
}
722742
}

0 commit comments

Comments
 (0)