Skip to content

Commit f8ad9c1

Browse files
authored
[chore] merge v0.51.0 (#29)
I needed to skip `parse_position_negative` test case due to conflict with local changes that was made [here](2202e80). Please me know if there is something better we could have done there.
2 parents 9c6ec54 + 8c31c8d commit f8ad9c1

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

+6860
-933
lines changed
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
18+
name: Prepare Rust Builder
19+
description: 'Prepare Rust Build Environment'
20+
inputs:
21+
rust-version:
22+
description: 'version of rust to install (e.g. stable)'
23+
required: true
24+
default: 'stable'
25+
targets:
26+
description: 'The toolchain targets to add, comma-separated'
27+
default: ''
28+
29+
runs:
30+
using: "composite"
31+
steps:
32+
- name: Setup Rust Toolchain
33+
shell: bash
34+
run: |
35+
echo "Installing ${{ inputs.rust-version }}"
36+
if [ -n "${{ inputs.targets}}" ]; then
37+
rustup toolchain install ${{ inputs.rust-version }} -t ${{ inputs.targets }}
38+
else
39+
rustup toolchain install ${{ inputs.rust-version }}
40+
fi
41+
rustup default ${{ inputs.rust-version }}
42+
rustup component add rustfmt clippy

.github/workflows/rust.yml

+26-29
Original file line numberDiff line numberDiff line change
@@ -7,52 +7,49 @@ jobs:
77
codestyle:
88
runs-on: ubuntu-latest
99
steps:
10-
- name: Set up Rust
11-
uses: hecrj/setup-rust-action@v1
10+
- uses: actions/checkout@v4
11+
- name: Setup Rust Toolchain
12+
uses: ./.github/actions/setup-builder
1213
with:
13-
components: rustfmt
1414
# Note that `nightly` is required for `license_template_path`, as
1515
# it's an unstable feature.
1616
rust-version: nightly
17-
- uses: actions/checkout@v2
1817
- run: cargo +nightly fmt -- --check --config-path <(echo 'license_template_path = "HEADER"')
1918

2019
lint:
2120
runs-on: ubuntu-latest
2221
steps:
23-
- name: Set up Rust
24-
uses: hecrj/setup-rust-action@v1
25-
with:
26-
components: clippy
27-
- uses: actions/checkout@v2
22+
- uses: actions/checkout@v4
23+
- name: Setup Rust Toolchain
24+
uses: ./.github/actions/setup-builder
2825
- run: cargo clippy --all-targets --all-features -- -D warnings
2926

3027
compile:
3128
runs-on: ubuntu-latest
3229
steps:
33-
- name: Set up Rust
34-
uses: hecrj/setup-rust-action@v1
35-
- uses: actions/checkout@master
30+
- uses: actions/checkout@v4
31+
- name: Setup Rust Toolchain
32+
uses: ./.github/actions/setup-builder
3633
- run: cargo check --all-targets --all-features
3734

3835
docs:
3936
runs-on: ubuntu-latest
4037
env:
4138
RUSTDOCFLAGS: "-Dwarnings"
4239
steps:
43-
- name: Set up Rust
44-
uses: hecrj/setup-rust-action@v1
45-
- uses: actions/checkout@master
40+
- uses: actions/checkout@v4
41+
- name: Setup Rust Toolchain
42+
uses: ./.github/actions/setup-builder
4643
- run: cargo doc --document-private-items --no-deps --workspace --all-features
4744

4845
compile-no-std:
4946
runs-on: ubuntu-latest
5047
steps:
51-
- name: Set up Rust
52-
uses: hecrj/setup-rust-action@v1
48+
- uses: actions/checkout@v4
49+
- name: Setup Rust Toolchain
50+
uses: ./.github/actions/setup-builder
5351
with:
5452
targets: 'thumbv6m-none-eabi'
55-
- uses: actions/checkout@master
5653
- run: cargo check --no-default-features --target thumbv6m-none-eabi
5754

5855
test:
@@ -61,8 +58,10 @@ jobs:
6158
rust: [stable, beta, nightly]
6259
runs-on: ubuntu-latest
6360
steps:
64-
- name: Setup Rust
65-
uses: hecrj/setup-rust-action@v1
61+
- name: Checkout
62+
uses: actions/checkout@v4
63+
- name: Setup Rust Toolchain
64+
uses: ./.github/actions/setup-builder
6665
with:
6766
rust-version: ${{ matrix.rust }}
6867
- name: Install Tarpaulin
@@ -71,16 +70,16 @@ jobs:
7170
crate: cargo-tarpaulin
7271
version: 0.14.2
7372
use-tool-cache: true
74-
- name: Checkout
75-
uses: actions/checkout@v2
7673
- name: Test
7774
run: cargo test --all-features
7875

7976
test-coverage:
8077
runs-on: ubuntu-latest
8178
steps:
82-
- name: Setup Rust
83-
uses: hecrj/setup-rust-action@v1
79+
- name: Checkout
80+
uses: actions/checkout@v4
81+
- name: Setup Rust Toolchain
82+
uses: ./.github/actions/setup-builder
8483
with:
8584
rust-version: stable
8685
- name: Install Tarpaulin
@@ -89,8 +88,6 @@ jobs:
8988
crate: cargo-tarpaulin
9089
version: 0.14.2
9190
use-tool-cache: true
92-
- name: Checkout
93-
uses: actions/checkout@v2
9491
- name: Coverage
9592
run: cargo tarpaulin -o Lcov --output-dir ./coverage
9693
- name: Coveralls
@@ -103,9 +100,9 @@ jobs:
103100
runs-on: ubuntu-latest
104101
needs: [test]
105102
steps:
106-
- name: Set up Rust
107-
uses: hecrj/setup-rust-action@v1
108-
- uses: actions/checkout@v2
103+
- uses: actions/checkout@v4
104+
- name: Setup Rust Toolchain
105+
uses: ./.github/actions/setup-builder
109106
- name: Publish
110107
shell: bash
111108
run: |

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ Cargo.lock
1616
.vscode
1717

1818
*.swp
19+
20+
.DS_store

CHANGELOG.md

+90
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,96 @@ changes that break via addition as "Added".
1010
## [Unreleased]
1111
Check https://github.com/sqlparser-rs/sqlparser-rs/commits/main for undocumented changes.
1212

13+
14+
## [0.51.0] 2024-09-11
15+
As always, huge props to @iffyio @jmhain and @lovasoa for their help reviewing and merging PRs 🙏.
16+
Without them this project would not be possible.
17+
18+
Reminder: we are in the final phases of moving sqlparser-rs into the Apache
19+
DataFusion project: https://github.com/sqlparser-rs/sqlparser-rs/issues/1294
20+
21+
### Fixed
22+
* Fix Hive table comment should be after table column definitions (#1413) - Thanks @git-hulk
23+
* Fix stack overflow in `parse_subexpr` (#1410) - Thanks @eejbyfeldt
24+
* Fix `INTERVAL` parsing to support expressions and units via dialect (#1398) - Thanks @samuelcolvin
25+
* Fix identifiers starting with `$` should be regarded as a placeholder in SQLite (#1402) - Thanks @git-hulk
26+
27+
### Added
28+
* Support for MSSQL table options (#1414) - Thanks @bombsimon
29+
* Test showing how negative constants are parsed (#1421) - Thanks @alamb
30+
* Support databricks dialect to dialect_from_str (#1416) - Thanks @milenkovicmalamb
31+
* Support `DROP|CLEAR|MATERIALIZE PROJECTION` syntax for ClickHouse (#1417) - Thanks @git-hulk
32+
* Support postgres `TRUNCATE` syntax (#1406) - Thanks @tobyhede
33+
* Support `CREATE INDEX` with clause (#1389) - Thanks @lewiszlw
34+
* Support parsing `CLUSTERED BY` clause for Hive (#1397) - Thanks @git-hulk
35+
* Support different `USE` statement syntaxes (#1387) - Thanks @kacpermuda
36+
* Support `ADD PROJECTION` syntax for ClickHouse (#1390) - Thanks @git-hulk
37+
38+
### Changed
39+
* Implement common traits for OneOrManyWithParens (#1368) - Thanks @gstvg
40+
* Cleanup parse_statement (#1407) - Thanks @samuelcolvin
41+
* Allow `DateTimeField::Custom` with `EXTRACT` in Postgres (#1394) - Thanks @samuelcolvin
42+
43+
44+
## [0.50.0] 2024-08-15
45+
Again, huge props to @iffyio @jmhain and @lovasoa for their help reviewing and merging PRs 🙏.
46+
Without them this project would not be possible.
47+
48+
Reminder: are in the process of moving sqlparser to governed as part of the Apache
49+
DataFusion project: https://github.com/sqlparser-rs/sqlparser-rs/issues/1294
50+
51+
### Fixed
52+
* Clippy 1.80 warnings (#1357) - Thanks @lovasoa
53+
54+
### Added
55+
* Support `STRUCT` and list of structs for DuckDB dialect (#1372) - Thanks @jayzhan211
56+
* Support custom lexical precedence in PostgreSQL dialect (#1379) - Thanks @samuelcolvin
57+
* Support `FREEZE|UNFREEZE PARTITION` syntax for ClickHouse (#1380) - Thanks @git-hulk
58+
* Support scale in `CEIL` and `FLOOR` functions (#1377) - Thanks @seve-martinez
59+
* Support `CREATE TRIGGER` and `DROP TRIGGER` statements (#1352) - Thanks @LucaCappelletti94
60+
* Support `EXTRACT` syntax for snowflake (#1374) - Thanks @seve-martinez
61+
* Support `ATTACH` / `DETACH PARTITION` for ClickHouse (#1362) - Thanks @git-hulk
62+
* Support Dialect level precedence, update Postgres Dialect to match Postgres (#1360) - Thanks @samuelcolvin
63+
* Support parsing empty map literal syntax for DuckDB and Generic dialects (#1361) - Thanks @goldmedal
64+
* Support `SETTINGS` clause for ClickHouse table-valued functions (#1358) - Thanks @Jesse-Bakker
65+
* Support `OPTIMIZE TABLE` statement for ClickHouse (#1359) - Thanks @git-hulk
66+
* Support `ON CLUSTER` in `ALTER TABLE` for ClickHouse (#1342) - Thanks @git-hulk
67+
* Support `GLOBAL` keyword before the join operator (#1353) - Thanks @git-hulk
68+
* Support postgres String Constants with Unicode Escapes (#1355) - Thanks @lovasoa
69+
* Support position with normal function call syntax for Snowflake (#1341) - Thanks @jmhain
70+
* Support `TABLE` keyword in `DESC|DESCRIBE|EXPLAIN TABLE` statement (#1351) - Thanks @git-hulk
71+
72+
### Changed
73+
* Only require `DESCRIBE TABLE` for Snowflake and ClickHouse dialect (#1386) - Thanks @ alamb
74+
* Rename (unreleased) `get_next_precedence_full` to `get_next_precedence_default` (#1378) - Thanks @samuelcolvin
75+
* Use local GitHub Action to replace setup-rust-action (#1371) - Thanks @git-hulk
76+
* Simplify arrow_cast tests (#1367) - Thanks @alamb
77+
* Update version of GitHub Actions (#1363) - Thanks @git-hulk
78+
* Make `Parser::maybe_parse` pub (#1364) - Thanks @Jesse-Bakker
79+
* Improve comments on 1Dialect` (#1366) - Thanks @alamb
80+
81+
82+
## [0.49.0] 2024-07-23
83+
As always, huge props to @iffyio @jmhain and @lovasoa for their help reviewing and merging PRs!
84+
85+
We are in the process of moving sqlparser to governed as part of the Apache
86+
DataFusion project: https://github.com/sqlparser-rs/sqlparser-rs/issues/1294
87+
88+
### Fixed
89+
* Fix quoted identifier regression edge-case with "from" in SELECT (#1346) - Thanks @alexander-beedie
90+
* Fix `AS` query clause should be after the create table options (#1339) - Thanks @git-hulk
91+
92+
### Added
93+
94+
* Support `MATERIALIZED`/`ALIAS`/`EPHERMERAL` default column options for ClickHouse (#1348) - Thanks @git-hulk
95+
* Support `()` as the `GROUP BY` nothing (#1347) - Thanks @git-hulk
96+
* Support Map literal syntax for DuckDB and Generic (#1344) - Thanks @goldmedal
97+
* Support subquery expression in `SET` expressions (#1343) - Thanks @iffyio
98+
* Support `WITH FILL` for ClickHouse (#1330) - Thanks @nickpresta
99+
* Support `PARTITION BY` for PostgreSQL in `CREATE TABLE` statement (#1338) - Thanks @git-hulk
100+
* Support of table function `WITH ORDINALITY` modifier for Postgres (#1337) - Thanks @git-hulk
101+
102+
13103
## [0.48.0] 2024-07-09
14104

15105
Huge shout out to @iffyio @jmhain and @lovasoa for their help reviewing and merging PRs!

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "sqlparser"
33
description = "Extensible SQL Lexer and Parser with support for ANSI SQL:2011"
4-
version = "0.48.0"
4+
version = "0.51.0"
55
authors = ["Andy Grove <[email protected]>"]
66
homepage = "https://github.com/sqlparser-rs/sqlparser-rs"
77
documentation = "https://docs.rs/sqlparser/"

src/ast/data_type.rs

+26-3
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ pub enum DataType {
302302
///
303303
/// [hive]: https://docs.cloudera.com/cdw-runtime/cloud/impala-sql-reference/topics/impala-struct.html
304304
/// [bigquery]: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#struct_type
305-
Struct(Vec<StructField>),
305+
Struct(Vec<StructField>, StructBracketKind),
306306
/// Union
307307
///
308308
/// [duckdb]: https://duckdb.org/docs/sql/data_types/union.html
@@ -319,6 +319,10 @@ pub enum DataType {
319319
/// [`SQLiteDialect`](crate::dialect::SQLiteDialect), from statements such
320320
/// as `CREATE TABLE t1 (a)`.
321321
Unspecified,
322+
/// Trigger data type, returned by functions associated with triggers
323+
///
324+
/// [postgresql]: https://www.postgresql.org/docs/current/plpgsql-trigger.html
325+
Trigger,
322326
}
323327

324328
impl fmt::Display for DataType {
@@ -513,9 +517,16 @@ impl fmt::Display for DataType {
513517
}
514518
write!(f, ")")
515519
}
516-
DataType::Struct(fields) => {
520+
DataType::Struct(fields, bracket) => {
517521
if !fields.is_empty() {
518-
write!(f, "STRUCT<{}>", display_comma_separated(fields))
522+
match bracket {
523+
StructBracketKind::Parentheses => {
524+
write!(f, "STRUCT({})", display_comma_separated(fields))
525+
}
526+
StructBracketKind::AngleBrackets => {
527+
write!(f, "STRUCT<{}>", display_comma_separated(fields))
528+
}
529+
}
519530
} else {
520531
write!(f, "STRUCT")
521532
}
@@ -543,6 +554,7 @@ impl fmt::Display for DataType {
543554
write!(f, "Nested({})", display_comma_separated(fields))
544555
}
545556
DataType::Unspecified => Ok(()),
557+
DataType::Trigger => write!(f, "TRIGGER"),
546558
}
547559
}
548560
}
@@ -613,6 +625,17 @@ fn format_clickhouse_datetime_precision_and_timezone(
613625
Ok(())
614626
}
615627

628+
/// Type of brackets used for `STRUCT` literals.
629+
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
630+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
631+
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
632+
pub enum StructBracketKind {
633+
/// Example: `STRUCT(a INT, b STRING)`
634+
Parentheses,
635+
/// Example: `STRUCT<a INT, b STRING>`
636+
AngleBrackets,
637+
}
638+
616639
/// Timestamp and Time data types information about TimeZone formatting.
617640
///
618641
/// This is more related to a display information than real differences between each variant. To

src/ast/dcl.rs

+27
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,30 @@ impl fmt::Display for AlterRoleOperation {
193193
}
194194
}
195195
}
196+
197+
/// A `USE` (`Statement::Use`) operation
198+
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
199+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
200+
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
201+
pub enum Use {
202+
Catalog(ObjectName), // e.g. `USE CATALOG foo.bar`
203+
Schema(ObjectName), // e.g. `USE SCHEMA foo.bar`
204+
Database(ObjectName), // e.g. `USE DATABASE foo.bar`
205+
Warehouse(ObjectName), // e.g. `USE WAREHOUSE foo.bar`
206+
Object(ObjectName), // e.g. `USE foo.bar`
207+
Default, // e.g. `USE DEFAULT`
208+
}
209+
210+
impl fmt::Display for Use {
211+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
212+
f.write_str("USE ")?;
213+
match self {
214+
Use::Catalog(name) => write!(f, "CATALOG {}", name),
215+
Use::Schema(name) => write!(f, "SCHEMA {}", name),
216+
Use::Database(name) => write!(f, "DATABASE {}", name),
217+
Use::Warehouse(name) => write!(f, "WAREHOUSE {}", name),
218+
Use::Object(name) => write!(f, "{}", name),
219+
Use::Default => write!(f, "DEFAULT"),
220+
}
221+
}
222+
}

0 commit comments

Comments
 (0)