Skip to content

Commit

Permalink
Merge branch 'update' of github.com:AikidoSec/datafusion-sqlparser-rs…
Browse files Browse the repository at this point in the history
… into sqlitedollar

* 'update' of github.com:AikidoSec/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)
  ...
  • Loading branch information
hansott committed Dec 26, 2024
2 parents d2d9c40 + 6359358 commit 296d3d4
Show file tree
Hide file tree
Showing 89 changed files with 12,647 additions and 3,227 deletions.
17 changes: 17 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

version: 2
updates:
- package-ecosystem: cargo
Expand Down
54 changes: 18 additions & 36 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

name: Rust

on: [push, pull_request]
Expand All @@ -10,7 +27,7 @@ jobs:
- uses: actions/checkout@v4
- name: Setup Rust Toolchain
uses: ./.github/actions/setup-builder
- run: cargo fmt -- --check
- run: cargo fmt --all -- --check

lint:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -68,38 +85,3 @@ jobs:
use-tool-cache: true
- name: Test
run: cargo test --all-features

test-coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust Toolchain
uses: ./.github/actions/setup-builder
with:
rust-version: stable
- name: Install Tarpaulin
uses: actions-rs/install@v0.1
with:
crate: cargo-tarpaulin
version: 0.14.2
use-tool-cache: true
- name: Coverage
run: cargo tarpaulin -o Lcov --output-dir ./coverage
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

publish-crate:
if: startsWith(github.ref, 'refs/tags/v0')
runs-on: ubuntu-latest
needs: [test]
steps:
- uses: actions/checkout@v4
- name: Setup Rust Toolchain
uses: ./.github/actions/setup-builder
- name: Publish
shell: bash
run: |
cargo publish --token ${{ secrets.CRATES_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/target/
/sqlparser_bench/target/
/derive/target/
dev/dist

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
Expand Down
1,180 changes: 5 additions & 1,175 deletions CHANGELOG.md

Large diffs are not rendered by default.

16 changes: 5 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
[package]
name = "sqlparser"
description = "Extensible SQL Lexer and Parser with support for ANSI SQL:2011"
version = "0.51.0"
authors = ["Andy Grove <andygrove73@gmail.com>"]
homepage = "https://github.com/sqlparser-rs/sqlparser-rs"
version = "0.53.0"
authors = ["Apache DataFusion <dev@datafusion.apache.org>"]
homepage = "https://github.com/apache/datafusion-sqlparser-rs"
documentation = "https://docs.rs/sqlparser/"
keywords = ["ansi", "sql", "lexer", "parser"]
repository = "https://github.com/sqlparser-rs/sqlparser-rs"
repository = "https://github.com/apache/datafusion-sqlparser-rs"
license = "Apache-2.0"
include = [
"src/**/*.rs",
Expand Down Expand Up @@ -51,19 +51,13 @@ serde = { version = "1.0", features = ["derive"], optional = true }
# of dev-dependencies because of
# https://github.com/rust-lang/cargo/issues/1596
serde_json = { version = "1.0", optional = true }
sqlparser_derive = { version = "0.2.0", path = "derive", optional = true }
sqlparser_derive = { version = "0.3.0", path = "derive", optional = true }

[dev-dependencies]
simple_logger = "5.0"
matches = "0.1"
pretty_assertions = "1"

[package.metadata.release]
# Instruct `cargo release` to not run `cargo publish` locally:
# https://github.com/sunng87/cargo-release/blob/master/docs/reference.md#config-fields
# See docs/releasing.md for details.
publish = false

[package.metadata.docs.rs]
# Document these features on docs.rs
features = ["serde", "visitor"]
59 changes: 56 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
<!---
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

# Extensible SQL Lexer and Parser for Rust

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


## Source Locations (Work in Progress)

This crate allows recovering source locations from AST nodes via the [Spanned]
trait, which can be used for advanced diagnostics tooling. Note that this
feature is a work in progress and many nodes report missing or inaccurate spans.
Please see [this ticket] for information on how to contribute missing
improvements.

[Spanned]: https://docs.rs/sqlparser/latest/sqlparser/ast/trait.Spanned.html
[this ticket]: https://github.com/apache/datafusion-sqlparser-rs/issues/1548

```rust
// Parse SQL
let ast = Parser::parse_sql(&GenericDialect, "SELECT A FROM B").unwrap();

// The source span can be retrieved with start and end locations
assert_eq!(ast[0].span(), Span {
start: Location::of(1, 1),
end: Location::of(1, 16),
});
```

## SQL compliance

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

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

### Benchmarking

There are several micro benchmarks in the `sqlparser_bench` directory.
You can run them with:

```
git checkout main
cd sqlparser_bench
cargo bench
git checkout <your branch>
cargo bench
```

## Licensing

Expand Down
Loading

0 comments on commit 296d3d4

Please sign in to comment.