Skip to content

Commit 6359358

Browse files
committed
* tag 'v0.53.0' of https://github.com/apache/datafusion-sqlparser-rs: (66 commits) Run cargo fmt in derive crate Add Apache license header to spans.rs Update version to 0.53.0 and add release notes (apache#1592) Add support for ODBC functions (apache#1585) Parse `INSERT` with subquery when lacking column names (apache#1586) Support INSERT OVERWRITE INTO syntax (apache#1584) Snowflake ALTER TABLE clustering options (apache#1579) Parse Snowflake USE ROLE and USE SECONDARY ROLES (apache#1578) Add support of the ENUM8|ENUM16 for ClickHouse dialect (apache#1574) Fix displaying WORK or TRANSACTION after BEGIN (apache#1565) Support parsing optional nulls handling for unique constraint (apache#1567) Support BIT column types (apache#1577) Encapsulate CreateFunction (apache#1573) Support Databricks struct literal (apache#1542) Update comments / docs for `Spanned` (apache#1549) Support snowflake double dot notation for object name (apache#1540) `json_object('k' VALUE 'v')` in postgres (apache#1547) Increase version of sqlparser_derive from 0.2.2 to 0.3.0 (apache#1571) Support MySQL size variants for BLOB and TEXT columns (apache#1564) Rename `TokenWithLocation` to `TokenWithSpan`, in backwards compatible way (apache#1562) ...
2 parents 4fdeb5c + e7d2c85 commit 6359358

Some content is hidden

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

89 files changed

+12647
-3227
lines changed

.github/dependabot.yml

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
118
version: 2
219
updates:
320
- package-ecosystem: cargo

.github/workflows/rust.yml

+18-36
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
118
name: Rust
219

320
on: [push, pull_request]
@@ -10,7 +27,7 @@ jobs:
1027
- uses: actions/checkout@v4
1128
- name: Setup Rust Toolchain
1229
uses: ./.github/actions/setup-builder
13-
- run: cargo fmt -- --check
30+
- run: cargo fmt --all -- --check
1431

1532
lint:
1633
runs-on: ubuntu-latest
@@ -68,38 +85,3 @@ jobs:
6885
use-tool-cache: true
6986
- name: Test
7087
run: cargo test --all-features
71-
72-
test-coverage:
73-
runs-on: ubuntu-latest
74-
steps:
75-
- name: Checkout
76-
uses: actions/checkout@v4
77-
- name: Setup Rust Toolchain
78-
uses: ./.github/actions/setup-builder
79-
with:
80-
rust-version: stable
81-
- name: Install Tarpaulin
82-
uses: actions-rs/[email protected]
83-
with:
84-
crate: cargo-tarpaulin
85-
version: 0.14.2
86-
use-tool-cache: true
87-
- name: Coverage
88-
run: cargo tarpaulin -o Lcov --output-dir ./coverage
89-
- name: Coveralls
90-
uses: coverallsapp/github-action@master
91-
with:
92-
github-token: ${{ secrets.GITHUB_TOKEN }}
93-
94-
publish-crate:
95-
if: startsWith(github.ref, 'refs/tags/v0')
96-
runs-on: ubuntu-latest
97-
needs: [test]
98-
steps:
99-
- uses: actions/checkout@v4
100-
- name: Setup Rust Toolchain
101-
uses: ./.github/actions/setup-builder
102-
- name: Publish
103-
shell: bash
104-
run: |
105-
cargo publish --token ${{ secrets.CRATES_TOKEN }}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/target/
44
/sqlparser_bench/target/
55
/derive/target/
6+
dev/dist
67

78
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
89
# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock

CHANGELOG.md

+5-1,175
Large diffs are not rendered by default.

Cargo.toml

+5-11
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
[package]
1919
name = "sqlparser"
2020
description = "Extensible SQL Lexer and Parser with support for ANSI SQL:2011"
21-
version = "0.51.0"
22-
authors = ["Andy Grove <[email protected]>"]
23-
homepage = "https://github.com/sqlparser-rs/sqlparser-rs"
21+
version = "0.53.0"
22+
authors = ["Apache DataFusion <[email protected]>"]
23+
homepage = "https://github.com/apache/datafusion-sqlparser-rs"
2424
documentation = "https://docs.rs/sqlparser/"
2525
keywords = ["ansi", "sql", "lexer", "parser"]
26-
repository = "https://github.com/sqlparser-rs/sqlparser-rs"
26+
repository = "https://github.com/apache/datafusion-sqlparser-rs"
2727
license = "Apache-2.0"
2828
include = [
2929
"src/**/*.rs",
@@ -51,19 +51,13 @@ serde = { version = "1.0", features = ["derive"], optional = true }
5151
# of dev-dependencies because of
5252
# https://github.com/rust-lang/cargo/issues/1596
5353
serde_json = { version = "1.0", optional = true }
54-
sqlparser_derive = { version = "0.2.0", path = "derive", optional = true }
54+
sqlparser_derive = { version = "0.3.0", path = "derive", optional = true }
5555

5656
[dev-dependencies]
5757
simple_logger = "5.0"
5858
matches = "0.1"
5959
pretty_assertions = "1"
6060

61-
[package.metadata.release]
62-
# Instruct `cargo release` to not run `cargo publish` locally:
63-
# https://github.com/sunng87/cargo-release/blob/master/docs/reference.md#config-fields
64-
# See docs/releasing.md for details.
65-
publish = false
66-
6761
[package.metadata.docs.rs]
6862
# Document these features on docs.rs
6963
features = ["serde", "visitor"]

README.md

+56-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
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+
120
# Extensible SQL Lexer and Parser for Rust
221

322
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
@@ -81,15 +100,37 @@ similar semantics are represented with the same AST. We welcome PRs to fix such
81100
issues and distinguish different syntaxes in the AST.
82101

83102

103+
## Source Locations (Work in Progress)
104+
105+
This crate allows recovering source locations from AST nodes via the [Spanned]
106+
trait, which can be used for advanced diagnostics tooling. Note that this
107+
feature is a work in progress and many nodes report missing or inaccurate spans.
108+
Please see [this ticket] for information on how to contribute missing
109+
improvements.
110+
111+
[Spanned]: https://docs.rs/sqlparser/latest/sqlparser/ast/trait.Spanned.html
112+
[this ticket]: https://github.com/apache/datafusion-sqlparser-rs/issues/1548
113+
114+
```rust
115+
// Parse SQL
116+
let ast = Parser::parse_sql(&GenericDialect, "SELECT A FROM B").unwrap();
117+
118+
// The source span can be retrieved with start and end locations
119+
assert_eq!(ast[0].span(), Span {
120+
start: Location::of(1, 1),
121+
end: Location::of(1, 16),
122+
});
123+
```
124+
84125
## SQL compliance
85126

86127
SQL was first standardized in 1987, and revisions of the standard have been
87128
published regularly since. Most revisions have added significant new features to
88129
the language, and as a result no database claims to support the full breadth of
89130
features. This parser currently supports most of the SQL-92 syntax, plus some
90-
syntax from newer versions that have been explicitly requested, plus some MSSQL,
91-
PostgreSQL, and other dialect-specific syntax. Whenever possible, the [online
92-
SQL:2016 grammar][sql-2016-grammar] is used to guide what syntax to accept.
131+
syntax from newer versions that have been explicitly requested, plus various
132+
other dialect-specific syntax. Whenever possible, the [online SQL:2016
133+
grammar][sql-2016-grammar] is used to guide what syntax to accept.
93134

94135
Unfortunately, stating anything more specific about compliance is difficult.
95136
There is no publicly available test suite that can assess compliance
@@ -191,6 +232,18 @@ Our goal as maintainers is to facilitate the integration
191232
of various features from various contributors, but not to provide the
192233
implementations ourselves, as we simply don't have the resources.
193234

235+
### Benchmarking
236+
237+
There are several micro benchmarks in the `sqlparser_bench` directory.
238+
You can run them with:
239+
240+
```
241+
git checkout main
242+
cd sqlparser_bench
243+
cargo bench
244+
git checkout <your branch>
245+
cargo bench
246+
```
194247

195248
## Licensing
196249

0 commit comments

Comments
 (0)