Skip to content

Commit cdaaaec

Browse files
committed
Merge main
2 parents 6c40625 + 222b7d1 commit cdaaaec

30 files changed

+2998
-365
lines changed
Lines changed: 42 additions & 0 deletions
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

Lines changed: 26 additions & 29 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,44 @@ 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+
## [0.50.0] 2024-08-15
14+
Again, huge props to @iffyio @jmhain and @lovasoa for their help reviewing and merging PRs 🙏.
15+
Without them this project would not be possible.
16+
17+
Reminder: are in the process of moving sqlparser to governed as part of the Apache
18+
DataFusion project: https://github.com/sqlparser-rs/sqlparser-rs/issues/1294
19+
20+
# Fixed
21+
* Clippy 1.80 warnings (#1357) - Thanks @lovasoa
22+
23+
# Added
24+
* Support `STRUCT` and list of structs for DuckDB dialect (#1372) - Thanks @jayzhan211
25+
* Support custom lexical precedence in PostgreSQL dialect (#1379) - Thanks @samuelcolvin
26+
* Support `FREEZE|UNFREEZE PARTITION` syntax for ClickHouse (#1380) - Thanks @git-hulk
27+
* Support scale in `CEIL` and `FLOOR` functions (#1377) - Thanks @seve-martinez
28+
* Support `CREATE TRIGGER` and `DROP TRIGGER` statements (#1352) - Thanks @LucaCappelletti94
29+
* Support `EXTRACT` syntax for snowflake (#1374) - Thanks @seve-martinez
30+
* Support `ATTACH` / `DETACH PARTITION` for ClickHouse (#1362) - Thanks @git-hulk
31+
* Support Dialect level precedence, update Postgres Dialect to match Postgres (#1360) - Thanks @samuelcolvin
32+
* Support parsing empty map literal syntax for DuckDB and Generic dialects (#1361) - Thanks @goldmedal
33+
* Support `SETTINGS` clause for ClickHouse table-valued functions (#1358) - Thanks @Jesse-Bakker
34+
* Support `OPTIMIZE TABLE` statement for ClickHouse (#1359) - Thanks @git-hulk
35+
* Support `ON CLUSTER` in `ALTER TABLE` for ClickHouse (#1342) - Thanks @git-hulk
36+
* Support `GLOBAL` keyword before the join operator (#1353) - Thanks @git-hulk
37+
* Support postgres String Constants with Unicode Escapes (#1355) - Thanks @lovasoa
38+
* Support position with normal function call syntax for Snowflake (#1341) - Thanks @jmhain
39+
* Support `TABLE` keyword in `DESC|DESCRIBE|EXPLAIN TABLE` statement (#1351) - Thanks @git-hulk
40+
41+
# Changed
42+
* Only require `DESCRIBE TABLE` for Snowflake and ClickHouse dialect (#1386) - Thanks @ alamb
43+
* Rename (unreleased) `get_next_precedence_full` to `get_next_precedence_default` (#1378) - Thanks @samuelcolvin
44+
* Use local GitHub Action to replace setup-rust-action (#1371) - Thanks @git-hulk
45+
* Simplify arrow_cast tests (#1367) - Thanks @alamb
46+
* Update version of GitHub Actions (#1363) - Thanks @git-hulk
47+
* Make `Parser::maybe_parse` pub (#1364) - Thanks @Jesse-Bakker
48+
* Improve comments on 1Dialect` (#1366) - Thanks @alamb
49+
50+
1351
## [0.49.0] 2024-07-23
1452
As always, huge props to @iffyio @jmhain and @lovasoa for their help reviewing and merging PRs!
1553

Cargo.toml

Lines changed: 1 addition & 1 deletion
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.49.0"
4+
version = "0.50.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

Lines changed: 26 additions & 3 deletions
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

Lines changed: 27 additions & 0 deletions
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)