Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
137 commits
Select commit Hold shift + click to select a range
172ba42
Add support for MSSQL's SELECT TOP N syntax (#150)
alexkyllo Jan 13, 2020
3255fd3
Add support to to table_name inside parenthesis
eyalsatori Apr 4, 2020
4ce0eb1
Fix a new clippy lint (`.nth(0)`) to unbreak CI
nickolay Apr 14, 2020
dcc624c
Make CI handle missing rustfmt in the nightly
nickolay Apr 14, 2020
baacc95
derive default for GenericDialect
alex-dukhno Apr 19, 2020
b9f1ff6
Merge pull request #159 to fix Travis CI
nickolay Apr 20, 2020
33303b2
Merge pull request #155 from eyalleshem/master
nickolay Apr 20, 2020
05a2921
Update comments (follow-up to PR #155)
nickolay Apr 20, 2020
c0b0b59
Add support for OFFSET with the ROWS keyword
madelynnblue Apr 13, 2020
5fe9060
Merge pull request #162 from alex-dukhno/derive-defaul-for-generic-di…
nickolay Apr 20, 2020
af852e7
Merge pull request #158 from mjibson/offset-rows
nickolay Apr 20, 2020
0686511
Update comments (follow-up to PR #158)
nickolay Apr 20, 2020
5ad578e
Implement CREATE TABLE IF NOT EXISTS (#163)
alex-dukhno Apr 21, 2020
40853fe
Fix a recently implemented clippy lint
nickolay May 10, 2020
327e6cd
Report an error for unterminated string literals
nickolay May 10, 2020
7d60bfd
Update CHANGELOG.md
nickolay May 10, 2020
f614481
Merge pull request #165 from nickolay/pr/unterminated-string-literal
nickolay May 26, 2020
8406a93
Port the changes made to travis configuration in #159 to GitHub workf…
nickolay May 26, 2020
2644bc4
Merge pull request #171 from nickolay/master
nickolay May 26, 2020
5aacc5e
add create index and drop index support
May 15, 2020
320d2f2
Update CHANGELOG.md and a fix last-minute review nit
nickolay May 27, 2020
789fcc8
Merge pull request #167 from mashuai/add_index_support
nickolay May 27, 2020
98f97d0
Add support for "on delete cascade" column option (#170)
c7hm4r May 27, 2020
8d5eaf9
Update CHANGELOG
nickolay May 27, 2020
a2f4996
Update README to point to SQL:2016, instead of 2011
nickolay May 26, 2020
1cf9e5e
Update README: we support bits and pieces from other dialects too
nickolay May 26, 2020
b28dd82
Merge pull request #172 from nickolay/pr/readme
nickolay May 27, 2020
91f769e
added create and drop schema
alex-dukhno May 28, 2020
c918ff0
Merge pull request #173 from alex-dukhno/create-schema
nickolay May 28, 2020
418b963
add nulls first/last support to order by expression (#176)
houqp May 30, 2020
5f3c1bd
Provide LISTAGG implementation (#174)
maxcountryman May 30, 2020
00dc490
Support the string concat operator (#178)
Dandandan Jun 2, 2020
b4699bd
Support bitwise and, or, xor (#181)
Dandandan Jun 3, 2020
d32df52
Accept &str in `Parse::parse_sql` (#182)
Dandandan Jun 3, 2020
6e6fae7
Add benchmarks using cargo bench / criterion (#190)
Dandandan Jun 7, 2020
af54eb0
Rework github actions, add code coverage (#186)
maxcountryman Jun 7, 2020
a42121d
Use binary search to speed up matching keywords (#191)
Dandandan Jun 7, 2020
10b0b7f
Update CHANGELOG (#192)
nickolay Jun 7, 2020
d842f49
Add line and column number to TokenizerError (#194)
Dandandan Jun 10, 2020
846c52f
Allow omitting units after INTERVAL (#184)
maxcountryman Jun 10, 2020
d9a7491
Various follow-ups to recent pushes
nickolay Jun 10, 2020
2f10153
Add serde support to AST structs and enums (#196)
panarch Jun 10, 2020
0fe3a8e
Use Token::EOF instead of Option<Token> (#195)
nickolay Jun 10, 2020
34548e8
Change Word::keyword to a enum (#193)
Dandandan Jun 11, 2020
6cdd4a1
Support general "typed string" literals (#187)
maxcountryman Jun 11, 2020
f4fbd9b
Take slice as input for parse_keywords (#199)
Dandandan Jun 11, 2020
a0f076a
Make the cli example print JSON (#197)
panarch Jun 12, 2020
68afa2a
Make FileFormat case insensitive (#200)
Dandandan Jun 12, 2020
b24dbe5
Replace FromStr with normal parser function for FileFormat (#201)
Dandandan Jun 13, 2020
fab6e28
Output DataType capitalized (#202)
Dandandan Jun 13, 2020
faeb7d4
Implement ALTER TABLE ADD COLUMN and RENAME (#203)
miuy56dc Jun 16, 2020
26361fd
Implement ALTER TABLE DROP COLUMN (#148)
ivanceras Jun 16, 2020
15d5f71
Add CREATE TABLE AS support (#206)
Dandandan Jun 23, 2020
05f8992
(cargo-release) version 0.5.1
andygrove Jun 26, 2020
1946791
(cargo-release) start next development iteration 0.5.2-alpha.0
andygrove Jun 26, 2020
0c82be5
Follow-up to the recent release (CHANGELOG and the bench crate)
nickolay Jun 26, 2020
0c83e5d
Support SQLite's WITHOUT ROWID in CREATE TABLE (#208)
miuy56dc Jun 26, 2020
a53f1d2
Support SQLite `CREATE VIRTUAL TABLE` (#209)
miuy56dc Jun 28, 2020
2a6d5f2
update cargo manifest (#214)
andygrove Jun 28, 2020
8cc7702
update branch references to `main` (#215)
maxcountryman Jul 2, 2020
f3b9edc
update travis badge to point to actions status (#219)
maxcountryman Jul 5, 2020
5cab189
Add TPCH reggression tests (#221)
Dandandan Jul 14, 2020
c24b0e0
Implement ASSERT statement (#226)
Dandandan Jul 16, 2020
583f22b
Remove PostgreSQL version of assert (#229)
Dandandan Jul 17, 2020
3a42b69
Release 0.6.0 (#232)
Dandandan Jul 20, 2020
f053383
Release 0.6.1
Dandandan Jul 20, 2020
bc9bfae
automate crate publishing
maxcountryman Jul 25, 2020
d2e4340
Support create or replace view/table (#239)
Dandandan Jul 27, 2020
8020b2e
Add Postgres-specific PREPARE, EXECUTE and DEALLOCATE (#243)
Jul 28, 2020
09ca14f
Support dialect-specific auto-increment column options for MySQL and …
miuy56dc Jul 28, 2020
d0db8a2
Run cargo fmt
nickolay Jul 28, 2020
3e880b5
Use consistent style for Display impls
nickolay Jul 27, 2020
9371652
Fix "unused stmt" warning in tests, with default features
nickolay Jul 28, 2020
9a2d86d
Change CREATE INDEX serialization to not end with a semicolon
nickolay Jul 28, 2020
a6e30b3
Fix typo in JSONFILE serialization
nickolay Jul 28, 2020
1337820
Merge pull request #245 from nickolay/cleanups
nickolay Jul 28, 2020
9e7e302
Support identifiers quoted with backticks in the MySQL dialect (#247)
miuy56dc Jul 30, 2020
4452f9b
Support specifying ASC/DESC in index columns (#249)
miuy56dc Jul 30, 2020
f8feff4
Add SQLite dialect (#248)
miuy56dc Jul 31, 2020
9c1a5a7
Don't fail parsing ALTER TABLE ADD COLUMN ending with a semicolon (#246)
miuy56dc Jul 31, 2020
76a911b
ensure we use nightly with fmt
maxcountryman Jul 31, 2020
cac3a8e
provide missing license header
maxcountryman Jul 31, 2020
1a70c6e
document initial release process
maxcountryman Jul 31, 2020
6b37c16
fix typo
maxcountryman Jul 31, 2020
580e4b1
Merge pull request #252 from ballista-compute/fixup/use-nightly-fmt
maxcountryman Jul 31, 2020
9351efb
update release instructions
maxcountryman Aug 1, 2020
1cc3bf4
Support named arguments in function invocations (#250)
eyalleshem Aug 2, 2020
caeb046
Enable dependabot for this repository
Dandandan Aug 4, 2020
a246d5d
Undo accidental commit
Dandandan Aug 4, 2020
61431b0
Support TABLE functions in FROM (#253)
eyalleshem Aug 5, 2020
5f3a40e
Dependency updates (#255)
Dandandan Aug 5, 2020
3871bbc
Enable dependabot for this repository (#256)
Dandandan Aug 5, 2020
1b46e82
Enable dialect specific behaviours in the parser (#254)
eyalleshem Aug 10, 2020
23f5c7e
Move parse_column_def below parse_columns
nickolay Jul 31, 2020
66505eb
Don't fail parsing a column definition with unexpected tokens
nickolay Aug 10, 2020
2c6c295
Refactor <column definition> parsing (#251)
nickolay Aug 10, 2020
f500a42
Add snowflake dialect (#259)
eyalleshem Aug 12, 2020
118a345
Merge pull request #238 from maxcountryman/feature/gh-action-releases
maxcountryman Aug 12, 2020
fcf1eb1
add a note about cargo release config
maxcountryman Aug 14, 2020
038ef98
Add Ballista to the README as a user of this crate (#262)
andygrove Aug 27, 2020
a5b7524
Fix clippy linting error, use enumerate (#266)
Dandandan Aug 27, 2020
e9aa87f
Update bigdecimal requirement from 0.1 to 0.2 (#268)
dependabot[bot] Sep 2, 2020
1c6077c
[snowflake] Support single line comments starting with '#' or '//' (#…
eyalleshem Sep 7, 2020
01a2a6b
Update CHANGELOG (#261)
nickolay Sep 7, 2020
cf7263c
Fix typo in the README
nickolay Sep 7, 2020
2f71324
Fix deprecated way of initializing SimpleLogger (#275)
Dandandan Sep 7, 2020
cc4f51f
Update releasing.md docs
nickolay Sep 27, 2020
0ac343a
Don't publish on the push of any tag
nickolay Sep 27, 2020
926b03a
Add parsing for PostgreSQL math operators (#267)
alex-dukhno Sep 30, 2020
1ac2083
Support IF NOT EXISTS for CREATE SCHEMA (#276)
alex-dukhno Oct 2, 2020
7dc5d4c
Follow-up to #275: Bump simple_logger version in Cargo.toml
nickolay Sep 26, 2020
54be391
Update CHANGELOG
nickolay Oct 5, 2020
99fb633
Move existing SF tests to sqlparser_snowflake.rs
nickolay Oct 5, 2020
9f772f0
Add support for Recursive CTEs (#278)
rhanqtl Oct 11, 2020
4128dfe
Introduce tests/test_utils/mod.rs and use it consistently
nickolay Oct 5, 2020
d9e044a
Extend one_statement_parses_to to also test parsing canonical SQL
nickolay Oct 12, 2020
ad72cda
[snowflake] Support specifying an alias after `FROM (table_factor)`
nickolay Oct 13, 2020
929fc67
Merge pull request #260 from eyalleshem/single_tables_in_parens
nickolay Oct 13, 2020
cbd3c6b
Merge pull request #263 from ballista-compute/documentation/cargo-rel…
nickolay Oct 13, 2020
17f2930
Introduce support for EXPLAIN [ANALYZE] [VERBOSE] <STATEMENT> syntax
ovr Dec 28, 2020
94ff468
Support ANALYZE TABLE syntax (#285)
Dandandan Dec 28, 2020
e18e8dc
Prepare 0.6.2
Dandandan Dec 28, 2020
d66294f
Add date
Dandandan Dec 28, 2020
26c281e
(cargo-release) version 0.6.2
Dandandan Dec 28, 2020
9930bdf
(cargo-release) start next development iteration 0.6.3-alpha.0
Dandandan Dec 28, 2020
97cd1c0
Release 0.7.0 instead
Dandandan Dec 28, 2020
e11b80e
(cargo-release) version 0.7.0
Dandandan Dec 28, 2020
200ed5e
(cargo-release) start next development iteration 0.7.1-alpha.0
Dandandan Dec 28, 2020
17f8eb9
Fix clippy lints (#287)
joshwd36 Jan 7, 2021
8a214f9
Implement Hive QL Parsing (#235)
hntd187 Feb 4, 2021
6f0b2dc
Implement SUBSTRING(col [FROM <expr>] [FOR <expr>]) syntax (#293)
Dandandan Feb 7, 2021
f40955e
Parse floats without leading number (#294)
Dandandan Feb 8, 2021
07342d5
Support parsing multiple show variables. (#290)
francis-du Feb 9, 2021
add8991
feat: support sqlite insert or statement (#281)
zhangli-pear Feb 9, 2021
a868ff6
Add release notes
Dandandan Feb 9, 2021
34cd794
(cargo-release) version 0.8.0
Dandandan Feb 9, 2021
43fef23
(cargo-release) start next development iteration 0.8.1-alpha.0
Dandandan Feb 9, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: cargo
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
- package-ecosystem: cargo
directory: "/sqlparser_bench"
schedule:
interval: daily
open-pull-requests-limit: 10
91 changes: 69 additions & 22 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,78 @@
name: Rust

on: [push]
on: [push, pull_request]

jobs:
build:

codestyle:
runs-on: ubuntu-latest
steps:
- name: Set up Rust
uses: hecrj/setup-rust-action@v1
with:
components: rustfmt
# Note that `nightly` is required for `license_template_path`, as
# it's an unstable feature.
rust-version: nightly
- uses: actions/checkout@v2
- run: cargo +nightly fmt -- --check --config-path <(echo 'license_template_path = "HEADER"')

lint:
runs-on: ubuntu-latest
steps:
- name: Set up Rust
uses: hecrj/setup-rust-action@v1
with:
components: clippy
- uses: actions/checkout@v2
- run: cargo clippy --all-targets --all-features -- -D warnings

compile:
runs-on: ubuntu-latest
steps:
- name: Set up Rust
uses: hecrj/setup-rust-action@v1
- uses: actions/checkout@master
- run: cargo check --all-targets --all-features

test:
strategy:
matrix:
rust: [stable, beta, nightly]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Setup Rust
run: |
rustup toolchain install nightly && rustup component add --toolchain nightly rustfmt
rustup toolchain install stable
rustup override set stable
# Clippy must be run first, as its lints are only triggered during
# compilation. Put another way: after a successful `cargo build`, `cargo
# clippy` is guaranteed to produce no results. This bug is known upstream:
# https://github.com/rust-lang/rust-clippy/issues/2604.
# - name: Clippy
# run: cargo clippy -- --all-targets --all-features -- -D warnings
- name: Check formatting
run: |
cargo +nightly fmt -- --check --config-path <(echo 'license_template_path = "HEADER"')
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
- name: Run tests for all features
run: cargo test --verbose -- all-features
uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{ matrix.rust }}
- name: Install Tarpaulin
uses: actions-rs/install@v0.1
with:
crate: cargo-tarpaulin
version: 0.14.2
use-tool-cache: true
- name: Checkout
uses: actions/checkout@v2
- name: Test
run: cargo test --all-features
- name: Coverage
if: matrix.rust == 'stable'
run: cargo tarpaulin -o Lcov --output-dir ./coverage
- name: Coveralls
if: matrix.rust == 'stable'
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:
- name: Set up Rust
uses: hecrj/setup-rust-action@v1
- uses: actions/checkout@v2
- 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
@@ -1,6 +1,7 @@
# Generated by Cargo
# will have compiled files and executables
/target/
/sqlparser_bench/target/

# 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
20 changes: 14 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ rust:
- stable

before_script:
# Travis installs rust with a non-default "minimal" profile, and advises us
# to add clippy manually:
- rustup component add clippy
# Unfortunately, this method often breaks on the nightly channel, where the
# most recent build might not have all the optional components.
# We explicitly specify `--profile default` to obtain the most recent nightly
# that has rustfmt (we don't care if it's a week old, as we need it only for
# an experimental flag):
- rustup toolchain install nightly --profile default

- pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH
- export PATH=$HOME/.cargo/bin:$PATH
# `cargo install` fails if the specified binary is already installed, and
Expand All @@ -33,13 +43,9 @@ before_script:
# rebuilds from scratch, ignoring the cache entirely.
#
# [0]: https://github.com/rust-lang/cargo/issues/2082
- cargo install cargo-update || echo "cargo-update already installed"
- cargo install cargo-travis || echo "cargo-travis already installed"
- cargo install cargo-update || echo "cargo-update already installed" # for `cargo install-update`
- cargo install cargo-travis || echo "cargo-travis already installed" # for `cargo coveralls`
- cargo install-update -a # updates cargo-travis, if the cached version is outdated
- rustup component add clippy
# The license_template_path setting we use to verify copyright headers is
# only available on the nightly rustfmt.
- rustup toolchain install nightly && rustup component add --toolchain nightly rustfmt

script:
# Clippy must be run first, as its lints are only triggered during
Expand All @@ -50,6 +56,8 @@ script:
- travis-cargo build
- travis-cargo test
- travis-cargo test -- all-features
# The license_template_path setting we use to verify copyright headers is
# only available on the nightly rustfmt.
- cargo +nightly fmt -- --check --config-path <(echo 'license_template_path = "HEADER"')

after_success:
Expand Down
91 changes: 89 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,96 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
Given that the parser produces a typed AST, any changes to the AST will technically be breaking and thus will result in a `0.(N+1)` version. We document changes that break via addition as "Added".

## [Unreleased]
Nothing here yet! Check https://github.com/andygrove/sqlparser-rs/commits/master for undocumented changes.
Check https://github.com/ballista-compute/sqlparser-rs/commits/main for undocumented changes.


## [0.5.0] - 2019-10-10
## [0.8.0] 2020-02-20

### Added
* Introduce Hive QL dialect `HiveDialect` and syntax (#235) - Thanks @hntd187!
* Add `SUBSTRING(col [FROM <expr>] [FOR <expr>])` syntax (#293)
* Support parsing floats without leading digits `.01` (#294)
* Support parsing multiple show variables (#290) - Thanks @francis-du!
* Support SQLite `INSERT OR [..]` syntax (#281) - Thanks @zhangli-pear!

## [0.7.0] 2020-12-28

### Changed
- Change the MySQL dialect to support `` `identifiers` `` quoted with backticks instead of the standard `"double-quoted"` identifiers (#247) - thanks @mashuai!
- Update bigdecimal requirement from 0.1 to 0.2 (#268)

### Added
- Enable dialect-specific behaviours in the parser (`dialect_of!()`) (#254) - thanks @eyalleshem!
- Support named arguments in function invocations (`ARG_NAME => val`) (#250) - thanks @eyalleshem!
- Support `TABLE()` functions in `FROM` (#253) - thanks @eyalleshem!
- Support Snowflake's single-line comments starting with '#' or '//' (#264) - thanks @eyalleshem!
- Support PostgreSQL `PREPARE`, `EXECUTE`, and `DEALLOCATE` (#243) - thanks @silathdiir!
- Support PostgreSQL math operators (#267) - thanks @alex-dukhno!
- Add SQLite dialect (#248) - thanks @mashuai!
- Add Snowflake dialect (#259) - thanks @eyalleshem!
- Support for Recursive CTEs - thanks @rhanqtl!
- Support `FROM (table_name) alias` syntax - thanks @eyalleshem!
- Support for `EXPLAIN [ANALYZE] VERBOSE` - thanks @ovr!
- Support `ANALYZE TABLE`
- DDL:
- Support `OR REPLACE` in `CREATE VIEW`/`TABLE` (#239) - thanks @Dandandan!
- Support specifying `ASC`/`DESC` in index columns (#249) - thanks @mashuai!
- Support SQLite `AUTOINCREMENT` and MySQL `AUTO_INCREMENT` column option in `CREATE TABLE` (#234) - thanks @mashuai!
- Support PostgreSQL `IF NOT EXISTS` for `CREATE SCHEMA` (#276) - thanks @alex-dukhno!

### Fixed
- Fix a typo in `JSONFILE` serialization, introduced in 0.3.1 (#237)
- Change `CREATE INDEX` serialization to not end with a semicolon, introduced in 0.5.1 (#245)
- Don't fail parsing `ALTER TABLE ADD COLUMN` ending with a semicolon, introduced in 0.5.1 (#246) - thanks @mashuai

## [0.6.1] - 2020-07-20

### Added
- Support BigQuery `ASSERT` statement (#226)

## [0.6.0] - 2020-07-20

### Added
- Support SQLite's `CREATE TABLE (...) WITHOUT ROWID` (#208) - thanks @mashuai!
- Support SQLite's `CREATE VIRTUAL TABLE` (#209) - thanks @mashuai!

## [0.5.1] - 2020-06-26
This release should have been called `0.6`, as it introduces multiple incompatible changes to the API. If you don't want to upgrade yet, you can revert to the previous version by changing your `Cargo.toml` to:

sqlparser = "= 0.5.0"


### Changed
- **`Parser::parse_sql` now accepts a `&str` instead of `String` (#182)** - thanks @Dandandan!
- Change `Ident` (previously a simple `String`) to store the parsed (unquoted) `value` of the identifier and the `quote_style` separately (#143) - thanks @apparebit!
- Support Snowflake's `FROM (table_name)` (#155) - thanks @eyalleshem!
- Add line and column number to TokenizerError (#194) - thanks @Dandandan!
- Use Token::EOF instead of Option<Token> (#195)
- Make the units keyword following `INTERVAL '...'` optional (#184) - thanks @maxcountryman!
- Generalize `DATE`/`TIME`/`TIMESTAMP` literals representation in the AST (`TypedString { data_type, value }`) and allow `DATE` and other keywords to be used as identifiers when not followed by a string (#187) - thanks @maxcountryman!
- Output DataType capitalized (`fmt::Display`) (#202) - thanks @Dandandan!

### Added
- Support MSSQL `TOP (<N>) [ PERCENT ] [ WITH TIES ]` (#150) - thanks @alexkyllo!
- Support MySQL `LIMIT row_count OFFSET offset` (not followed by `ROW` or `ROWS`) and remember which variant was parsed (#158) - thanks @mjibson!
- Support PostgreSQL `CREATE TABLE IF NOT EXISTS table_name` (#163) - thanks @alex-dukhno!
- Support basic forms of `CREATE INDEX` and `DROP INDEX` (#167) - thanks @mashuai!
- Support `ON { UPDATE | DELETE } { RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT }` in `FOREIGN KEY` constraints (#170) - thanks @c7hm4r!
- Support basic forms of `CREATE SCHEMA` and `DROP SCHEMA` (#173) - thanks @alex-dukhno!
- Support `NULLS FIRST`/`LAST` in `ORDER BY` expressions (#176) - thanks @houqp!
- Support `LISTAGG()` (#174) - thanks @maxcountryman!
- Support the string concatentation operator `||` (#178) - thanks @Dandandan!
- Support bitwise AND (`&`), OR (`|`), XOR (`^`) (#181) - thanks @Dandandan!
- Add serde support to AST structs and enums (#196) - thanks @panarch!
- Support `ALTER TABLE ADD COLUMN`, `RENAME COLUMN`, and `RENAME TO` (#203) - thanks @mashuai!
- Support `ALTER TABLE DROP COLUMN` (#148) - thanks @ivanceras!
- Support `CREATE TABLE ... AS ...` (#206) - thanks @Dandandan!

### Fixed
- Report an error for unterminated string literals (#165)
- Make file format (`STORED AS`) case insensitive (#200) and don't allow quoting it (#201) - thanks @Dandandan!

## [0.5.0] - 2019-10-10

### Changed
- Replace the `Value::Long(u64)` and `Value::Double(f64)` variants with `Value::Number(String)` to avoid losing precision when parsing decimal literals (#130) - thanks @benesch!
Expand Down Expand Up @@ -122,3 +208,4 @@ We don't have a changelog for the changes made in 2018, but thanks to @crw5996,

## [0.1.0] - 2018-09-03
Initial release

27 changes: 21 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[package]
name = "sqlparser"
description = "Extensible SQL Lexer and Parser with support for ANSI SQL:2011"
version = "0.5.1-alpha-0"
version = "0.8.1-alpha.0"
authors = ["Andy Grove <andygrove73@gmail.com>"]
homepage = "https://github.com/andygrove/sqlparser-rs"
homepage = "https://github.com/ballista-compute/sqlparser-rs"
documentation = "https://docs.rs/sqlparser/"
keywords = [ "ansi", "sql", "lexer", "parser" ]
repository = "https://github.com/andygrove/sqlparser-rs"
repository = "https://github.com/ballista-compute/sqlparser-rs"
license = "Apache-2.0"
include = [
"src/**/*.rs",
Expand All @@ -18,10 +18,25 @@ edition = "2018"
name = "sqlparser"
path = "src/lib.rs"

[features]
# Enable JSON output in the `cli` example:
json_example = ["serde_json", "serde"]

[dependencies]
bigdecimal = { version = "0.1.0", optional = true }
log = "0.4.5"
bigdecimal = { version = "0.2", features = ["serde"], optional = true }
log = "0.4"
serde = { version = "1.0", features = ["derive"], optional = true }
# serde_json is only used in examples/cli, but we have to put it outside
# of dev-dependencies because of
# https://github.com/rust-lang/cargo/issues/1596
serde_json = { version = "1.0", optional = true }

[dev-dependencies]
simple_logger = "1.0.1"
simple_logger = "1.9"
matches = "0.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.
disable-publish = true
35 changes: 20 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Version](https://img.shields.io/crates/v/sqlparser.svg)](https://crates.io/crates/sqlparser)
[![Build Status](https://travis-ci.org/andygrove/sqlparser-rs.svg?branch=master)](https://travis-ci.org/andygrove/sqlparser-rs)
[![Coverage Status](https://coveralls.io/repos/github/andygrove/sqlparser-rs/badge.svg?branch=master)](https://coveralls.io/github/andygrove/sqlparser-rs?branch=master)
[![Build Status](https://github.com/ballista-compute/sqlparser-rs/workflows/Rust/badge.svg?branch=main)](https://github.com/ballista-compute/sqlparser-rs/actions?query=workflow%3ARust+branch%3Amain)
[![Coverage Status](https://coveralls.io/repos/github/ballista-compute/sqlparser-rs/badge.svg?branch=main)](https://coveralls.io/github/ballista-compute/sqlparser-rs?branch=main)
[![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)

The goal of this project is to build a SQL lexer and parser capable of parsing
SQL that conforms with the [ANSI/ISO SQL standard][sql-standard] while also
making it easy to support custom dialects so that this crate can be used as a
foundation for vendor-specific parsers.

This parser is currently being used by the [DataFusion] query engine and
[LocustDB].
This parser is currently being used by the [DataFusion] query engine,
[LocustDB], and [Ballista].

## Example

Expand All @@ -29,7 +29,7 @@ let sql = "SELECT a, b, 123, myfunc(b) \

let dialect = GenericDialect {}; // or AnsiDialect, or your own dialect ...

let ast = Parser::parse_sql(&dialect, sql.to_string()).unwrap();
let ast = Parser::parse_sql(&dialect, sql).unwrap();

println!("AST: {:?}", ast);
```
Expand All @@ -40,17 +40,21 @@ This outputs
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 })]
```

## Command line
To parse a file and dump the results as JSON:
```
$ cargo run --features json_example --example cli FILENAME.sql [--dialectname]
```

## 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-
and PostgreSQL-specific syntax. Whenever possible, the [online SQL:2011
grammar][sql-2011-grammar] is used to guide what syntax to accept. (We will
happily accept changes that conform to the SQL:2016 syntax as well, but that
edition's grammar is not yet available online.)
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.

Unfortunately, stating anything more specific about compliance is difficult.
There is no publicly available test suite that can assess compliance
Expand Down Expand Up @@ -105,8 +109,8 @@ If you are unable to submit a patch, feel free to file an issue instead. Please
try to include:

* some representative examples of the syntax you wish to support or fix;
* the relevant bits of the [SQL grammar][sql-2011-grammar], if the syntax is
part of SQL:2011; and
* the relevant bits of the [SQL grammar][sql-2016-grammar], if the syntax is
part of SQL:2016; and
* links to documentation for the feature for a few of the most popular
databases that support it.

Expand All @@ -119,9 +123,10 @@ resources.

[tdop-tutorial]: https://eli.thegreenplace.net/2010/01/02/top-down-operator-precedence-parsing
[`cargo fmt`]: https://github.com/rust-lang/rustfmt#on-the-stable-toolchain
[current issues]: https://github.com/andygrove/sqlparser-rs/issues
[current issues]: https://github.com/ballista-compute/sqlparser-rs/issues
[DataFusion]: https://github.com/apache/arrow/tree/master/rust/datafusion
[LocustDB]: https://github.com/cswinter/LocustDB
[Ballista]: https://github.com/ballista-compute/ballista
[Pratt Parser]: https://tdop.github.io/
[sql-2011-grammar]: https://jakewheat.github.io/sql-overview/sql-2011-foundation-grammar.html
[sql-standard]: https://en.wikipedia.org/wiki/ISO/IEC_9075
[sql-2016-grammar]: https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html
[sql-standard]: https://en.wikipedia.org/wiki/ISO/IEC_9075
Loading