Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
6523dab
Allow foreign table constraint without columns (#1608)
ramnivas Dec 19, 2024
eae5629
Support optional table for `ANALYZE` statement (#1599)
yuyang-ok Dec 19, 2024
c973df3
Support DOUBLE data types with precision for Mysql (#1611)
artorias1024 Dec 19, 2024
84e82e6
Add `#[recursive]` (#1522)
blaginin Dec 19, 2024
cd898cb
Support arbitrary composite access expressions (#1600)
ayman-sigma Dec 22, 2024
0647a4a
Consolidate `MapAccess`, and `Subscript` into `CompoundExpr` to handl…
goldmedal Dec 22, 2024
27822e2
Handle empty projection in Postgres SELECT statements (#1613)
tobyhede Dec 22, 2024
14cefc4
Merge composite and compound expr test cases (#1615)
iffyio Dec 22, 2024
024a878
Support Snowflake Update-From-Select (#1604)
yuval-illumex Dec 24, 2024
df3c565
Improve parsing performance by reducing token cloning (#1587)
davisp Dec 24, 2024
d89cf80
Improve Parser documentation (#1617)
alamb Dec 27, 2024
7dbf31b
Add support for DROP EXTENSION (#1610)
ramnivas Dec 27, 2024
6daa4b0
Refactor advancing token to avoid duplication, avoid borrow checker i…
alamb Dec 27, 2024
d0d4153
Fix the parsing result for the special double number (#1621)
goldmedal Dec 28, 2024
48f025f
SQLite: Allow dollar signs in placeholder names (#1620)
hansott Dec 28, 2024
77b5bd6
Improve error for an unexpected token after DROP (#1623)
ramnivas Dec 28, 2024
539db9f
Fix `sqlparser_bench` benchmark compilation (#1625)
alamb Dec 29, 2024
3db1b44
Improve parsing speed by avoiding some clones in parse_identifier (#1…
alamb Dec 29, 2024
fe36020
Simplify `parse_keyword_apis` more (#1626)
alamb Dec 29, 2024
3bad04e
Test benchmarks and Improve benchmark README.md (#1627)
alamb Jan 1, 2025
94ea206
Add support for MYSQL's `RENAME TABLE` (#1616)
wugeer Jan 1, 2025
8bc63f0
Correctly tokenize nested comments (#1629)
hansott Jan 5, 2025
02d60cc
Add support for USE SECONDARY ROLE (vs. ROLES) (#1637)
yoavcloud Jan 5, 2025
e23877c
Add support for various Snowflake grantees (#1640)
yoavcloud Jan 5, 2025
17e22f0
Add support for the SQL OVERLAPS predicate (#1638)
yoavcloud Jan 6, 2025
4c6af0a
Add support for Snowflake LIST and REMOVE (#1639)
yoavcloud Jan 6, 2025
8cfc462
Add support for MySQL's INSERT INTO ... SET syntax (#1641)
yoavcloud Jan 6, 2025
0cd49fb
Start new line if \r in Postgres dialect (#1647)
hansott Jan 7, 2025
62bcaa1
Support pluralized time units (#1630)
wugeer Jan 8, 2025
397bceb
Replace `ReferentialAction` enum in `DROP` statements (#1648)
stepancheg Jan 8, 2025
687ce2d
Add support for MS-SQL BEGIN/END TRY/CATCH (#1649)
yoavcloud Jan 8, 2025
4fdf5e1
Fix MySQL parsing of GRANT, REVOKE, and CREATE VIEW (#1538)
mvzink Jan 9, 2025
5a761dd
Add support for the Snowflake MINUS set operator (#1652)
yoavcloud Jan 9, 2025
c54ba4d
ALTER TABLE DROP {COLUMN|CONSTRAINT} RESTRICT (#1651)
stepancheg Jan 10, 2025
b09514e
feat: support `INSERT INTO [TABLE] FUNCTION` of Clickhouse (#1633)
byte-sourcerer Jan 10, 2025
0c3b6c0
Add support for ClickHouse `FORMAT` on `INSERT` (#1628)
bombsimon Jan 10, 2025
3b4dc0f
MsSQL SET for session params (#1646)
yoavcloud Jan 11, 2025
c808c4e
Correctly look for end delimiter dollar quoted string (#1650)
hansott Jan 12, 2025
6507484
Support single line comments starting with '#' for Hive (#1654)
wugeer Jan 13, 2025
7f99d7b
Merge branch 'main' into dev
linhr Jan 14, 2025
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
8 changes: 8 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ jobs:
uses: ./.github/actions/setup-builder
- run: cargo clippy --all-targets --all-features -- -D warnings

benchmark-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Rust Toolchain
uses: ./.github/actions/setup-builder
- run: cd sqlparser_bench && cargo clippy --all-targets --all-features -- -D warnings

compile:
runs-on: ubuntu-latest
steps:
Expand Down
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,18 @@ name = "sqlparser"
path = "src/lib.rs"

[features]
default = ["std"]
default = ["std", "recursive-protection"]
std = []
recursive-protection = ["std", "recursive"]
# Enable JSON output in the `cli` example:
json_example = ["serde_json", "serde"]
visitor = ["sqlparser_derive"]

[dependencies]
bigdecimal = { version = "0.4.1", features = ["serde"], optional = true }
log = "0.4"
recursive = { version = "0.1.1", optional = true}

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
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ The following optional [crate features](https://doc.rust-lang.org/cargo/referen

* `serde`: Adds [Serde](https://serde.rs/) support by implementing `Serialize` and `Deserialize` for all AST nodes.
* `visitor`: Adds a `Visitor` capable of recursively walking the AST tree.

* `recursive-protection` (enabled by default), uses [recursive](https://docs.rs/recursive/latest/recursive/) for stack overflow protection.

## Syntax vs Semantics

Expand Down Expand Up @@ -248,11 +248,14 @@ You can run them with:
```
git checkout main
cd sqlparser_bench
cargo bench
cargo bench -- --save-baseline main
git checkout <your branch>
cargo bench
cargo bench -- --baseline main
```

By adding the `--save-baseline main` and `--baseline main` you can track the
progress of your improvements as you continue working on the feature branch.

## Licensing

All code in this repository is licensed under the [Apache Software License 2.0](LICENSE.txt).
Expand Down
3 changes: 3 additions & 0 deletions derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ fn derive_visit(input: proc_macro::TokenStream, visit_type: &VisitType) -> proc_

let expanded = quote! {
// The generated impl.
// Note that it uses [`recursive::recursive`] to protect from stack overflow.
// See tests in https://github.com/apache/datafusion-sqlparser-rs/pull/1522/ for more info.
impl #impl_generics sqlparser::ast::#visit_trait for #name #ty_generics #where_clause {
#[cfg_attr(feature = "recursive-protection", recursive::recursive)]
fn visit<V: sqlparser::ast::#visitor_trait>(
&#modifier self,
visitor: &mut V
Expand Down
24 changes: 23 additions & 1 deletion sqlparser_bench/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,26 @@
under the License.
-->

Benchmarks for sqlparser. See [the main README](../README.md) for more information.
Benchmarks for sqlparser. See [the main README](../README.md) for more information.

Note: this is in a separate, non workspace crate to avoid adding a dependency
on `criterion` to the main crate (which complicates testing without std).

# Running Benchmarks

```shell
cargo bench --bench sqlparser_bench
```

# Profiling

Note you can generate a [flamegraph] using the following command:

```shell
cargo flamegraph --bench sqlparser_bench
```

[flamegraph]: https://crates.io/crates/flamegraph

Here is an example flamegraph:
![flamegraph](img/flamegraph.svg)
39 changes: 39 additions & 0 deletions sqlparser_bench/benches/sqlparser_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,45 @@ fn basic_queries(c: &mut Criterion) {
group.bench_function("sqlparser::with_select", |b| {
b.iter(|| Parser::parse_sql(&dialect, with_query).unwrap());
});

let large_statement = {
let expressions = (0..1000)
.map(|n| format!("FN_{}(COL_{})", n, n))
.collect::<Vec<_>>()
.join(", ");
let tables = (0..1000)
.map(|n| format!("TABLE_{}", n))
.collect::<Vec<_>>()
.join(" JOIN ");
let where_condition = (0..1000)
.map(|n| format!("COL_{} = {}", n, n))
.collect::<Vec<_>>()
.join(" OR ");
let order_condition = (0..1000)
.map(|n| format!("COL_{} DESC", n))
.collect::<Vec<_>>()
.join(", ");

format!(
"SELECT {} FROM {} WHERE {} ORDER BY {}",
expressions, tables, where_condition, order_condition
)
};

group.bench_function("parse_large_statement", |b| {
b.iter(|| Parser::parse_sql(&dialect, criterion::black_box(large_statement.as_str())));
});

let large_statement = Parser::parse_sql(&dialect, large_statement.as_str())
.unwrap()
.pop()
.unwrap();

group.bench_function("format_large_statement", |b| {
b.iter(|| {
let _formatted_query = large_statement.to_string();
});
});
}

criterion_group!(benches, basic_queries);
Expand Down
Loading
Loading