Skip to content

Commit

Permalink
[chore] merge v0.51.0 (#29)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ayman-sigma authored Nov 19, 2024
2 parents 9c6ec54 + 8c31c8d commit f8ad9c1
Show file tree
Hide file tree
Showing 45 changed files with 6,860 additions and 933 deletions.
42 changes: 42 additions & 0 deletions .github/actions/setup-builder/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 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: Prepare Rust Builder
description: 'Prepare Rust Build Environment'
inputs:
rust-version:
description: 'version of rust to install (e.g. stable)'
required: true
default: 'stable'
targets:
description: 'The toolchain targets to add, comma-separated'
default: ''

runs:
using: "composite"
steps:
- name: Setup Rust Toolchain
shell: bash
run: |
echo "Installing ${{ inputs.rust-version }}"
if [ -n "${{ inputs.targets}}" ]; then
rustup toolchain install ${{ inputs.rust-version }} -t ${{ inputs.targets }}
else
rustup toolchain install ${{ inputs.rust-version }}
fi
rustup default ${{ inputs.rust-version }}
rustup component add rustfmt clippy
55 changes: 26 additions & 29 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,49 @@ jobs:
codestyle:
runs-on: ubuntu-latest
steps:
- name: Set up Rust
uses: hecrj/setup-rust-action@v1
- uses: actions/checkout@v4
- name: Setup Rust Toolchain
uses: ./.github/actions/setup-builder
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
- uses: actions/checkout@v4
- name: Setup Rust Toolchain
uses: ./.github/actions/setup-builder
- 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
- uses: actions/checkout@v4
- name: Setup Rust Toolchain
uses: ./.github/actions/setup-builder
- run: cargo check --all-targets --all-features

docs:
runs-on: ubuntu-latest
env:
RUSTDOCFLAGS: "-Dwarnings"
steps:
- name: Set up Rust
uses: hecrj/setup-rust-action@v1
- uses: actions/checkout@master
- uses: actions/checkout@v4
- name: Setup Rust Toolchain
uses: ./.github/actions/setup-builder
- run: cargo doc --document-private-items --no-deps --workspace --all-features

compile-no-std:
runs-on: ubuntu-latest
steps:
- name: Set up Rust
uses: hecrj/setup-rust-action@v1
- uses: actions/checkout@v4
- name: Setup Rust Toolchain
uses: ./.github/actions/setup-builder
with:
targets: 'thumbv6m-none-eabi'
- uses: actions/checkout@master
- run: cargo check --no-default-features --target thumbv6m-none-eabi

test:
Expand All @@ -61,8 +58,10 @@ jobs:
rust: [stable, beta, nightly]
runs-on: ubuntu-latest
steps:
- name: Setup Rust
uses: hecrj/setup-rust-action@v1
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust Toolchain
uses: ./.github/actions/setup-builder
with:
rust-version: ${{ matrix.rust }}
- name: Install Tarpaulin
Expand All @@ -71,16 +70,16 @@ jobs:
crate: cargo-tarpaulin
version: 0.14.2
use-tool-cache: true
- name: Checkout
uses: actions/checkout@v2
- name: Test
run: cargo test --all-features

test-coverage:
runs-on: ubuntu-latest
steps:
- name: Setup Rust
uses: hecrj/setup-rust-action@v1
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust Toolchain
uses: ./.github/actions/setup-builder
with:
rust-version: stable
- name: Install Tarpaulin
Expand All @@ -89,8 +88,6 @@ jobs:
crate: cargo-tarpaulin
version: 0.14.2
use-tool-cache: true
- name: Checkout
uses: actions/checkout@v2
- name: Coverage
run: cargo tarpaulin -o Lcov --output-dir ./coverage
- name: Coveralls
Expand All @@ -103,9 +100,9 @@ jobs:
runs-on: ubuntu-latest
needs: [test]
steps:
- name: Set up Rust
uses: hecrj/setup-rust-action@v1
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Setup Rust Toolchain
uses: ./.github/actions/setup-builder
- name: Publish
shell: bash
run: |
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ Cargo.lock
.vscode

*.swp

.DS_store
90 changes: 90 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,96 @@ changes that break via addition as "Added".
## [Unreleased]
Check https://github.com/sqlparser-rs/sqlparser-rs/commits/main for undocumented changes.


## [0.51.0] 2024-09-11
As always, huge props to @iffyio @jmhain and @lovasoa for their help reviewing and merging PRs 🙏.
Without them this project would not be possible.

Reminder: we are in the final phases of moving sqlparser-rs into the Apache
DataFusion project: https://github.com/sqlparser-rs/sqlparser-rs/issues/1294

### Fixed
* Fix Hive table comment should be after table column definitions (#1413) - Thanks @git-hulk
* Fix stack overflow in `parse_subexpr` (#1410) - Thanks @eejbyfeldt
* Fix `INTERVAL` parsing to support expressions and units via dialect (#1398) - Thanks @samuelcolvin
* Fix identifiers starting with `$` should be regarded as a placeholder in SQLite (#1402) - Thanks @git-hulk

### Added
* Support for MSSQL table options (#1414) - Thanks @bombsimon
* Test showing how negative constants are parsed (#1421) - Thanks @alamb
* Support databricks dialect to dialect_from_str (#1416) - Thanks @milenkovicmalamb
* Support `DROP|CLEAR|MATERIALIZE PROJECTION` syntax for ClickHouse (#1417) - Thanks @git-hulk
* Support postgres `TRUNCATE` syntax (#1406) - Thanks @tobyhede
* Support `CREATE INDEX` with clause (#1389) - Thanks @lewiszlw
* Support parsing `CLUSTERED BY` clause for Hive (#1397) - Thanks @git-hulk
* Support different `USE` statement syntaxes (#1387) - Thanks @kacpermuda
* Support `ADD PROJECTION` syntax for ClickHouse (#1390) - Thanks @git-hulk

### Changed
* Implement common traits for OneOrManyWithParens (#1368) - Thanks @gstvg
* Cleanup parse_statement (#1407) - Thanks @samuelcolvin
* Allow `DateTimeField::Custom` with `EXTRACT` in Postgres (#1394) - Thanks @samuelcolvin


## [0.50.0] 2024-08-15
Again, huge props to @iffyio @jmhain and @lovasoa for their help reviewing and merging PRs 🙏.
Without them this project would not be possible.

Reminder: are in the process of moving sqlparser to governed as part of the Apache
DataFusion project: https://github.com/sqlparser-rs/sqlparser-rs/issues/1294

### Fixed
* Clippy 1.80 warnings (#1357) - Thanks @lovasoa

### Added
* Support `STRUCT` and list of structs for DuckDB dialect (#1372) - Thanks @jayzhan211
* Support custom lexical precedence in PostgreSQL dialect (#1379) - Thanks @samuelcolvin
* Support `FREEZE|UNFREEZE PARTITION` syntax for ClickHouse (#1380) - Thanks @git-hulk
* Support scale in `CEIL` and `FLOOR` functions (#1377) - Thanks @seve-martinez
* Support `CREATE TRIGGER` and `DROP TRIGGER` statements (#1352) - Thanks @LucaCappelletti94
* Support `EXTRACT` syntax for snowflake (#1374) - Thanks @seve-martinez
* Support `ATTACH` / `DETACH PARTITION` for ClickHouse (#1362) - Thanks @git-hulk
* Support Dialect level precedence, update Postgres Dialect to match Postgres (#1360) - Thanks @samuelcolvin
* Support parsing empty map literal syntax for DuckDB and Generic dialects (#1361) - Thanks @goldmedal
* Support `SETTINGS` clause for ClickHouse table-valued functions (#1358) - Thanks @Jesse-Bakker
* Support `OPTIMIZE TABLE` statement for ClickHouse (#1359) - Thanks @git-hulk
* Support `ON CLUSTER` in `ALTER TABLE` for ClickHouse (#1342) - Thanks @git-hulk
* Support `GLOBAL` keyword before the join operator (#1353) - Thanks @git-hulk
* Support postgres String Constants with Unicode Escapes (#1355) - Thanks @lovasoa
* Support position with normal function call syntax for Snowflake (#1341) - Thanks @jmhain
* Support `TABLE` keyword in `DESC|DESCRIBE|EXPLAIN TABLE` statement (#1351) - Thanks @git-hulk

### Changed
* Only require `DESCRIBE TABLE` for Snowflake and ClickHouse dialect (#1386) - Thanks @ alamb
* Rename (unreleased) `get_next_precedence_full` to `get_next_precedence_default` (#1378) - Thanks @samuelcolvin
* Use local GitHub Action to replace setup-rust-action (#1371) - Thanks @git-hulk
* Simplify arrow_cast tests (#1367) - Thanks @alamb
* Update version of GitHub Actions (#1363) - Thanks @git-hulk
* Make `Parser::maybe_parse` pub (#1364) - Thanks @Jesse-Bakker
* Improve comments on 1Dialect` (#1366) - Thanks @alamb


## [0.49.0] 2024-07-23
As always, huge props to @iffyio @jmhain and @lovasoa for their help reviewing and merging PRs!

We are in the process of moving sqlparser to governed as part of the Apache
DataFusion project: https://github.com/sqlparser-rs/sqlparser-rs/issues/1294

### Fixed
* Fix quoted identifier regression edge-case with "from" in SELECT (#1346) - Thanks @alexander-beedie
* Fix `AS` query clause should be after the create table options (#1339) - Thanks @git-hulk

### Added

* Support `MATERIALIZED`/`ALIAS`/`EPHERMERAL` default column options for ClickHouse (#1348) - Thanks @git-hulk
* Support `()` as the `GROUP BY` nothing (#1347) - Thanks @git-hulk
* Support Map literal syntax for DuckDB and Generic (#1344) - Thanks @goldmedal
* Support subquery expression in `SET` expressions (#1343) - Thanks @iffyio
* Support `WITH FILL` for ClickHouse (#1330) - Thanks @nickpresta
* Support `PARTITION BY` for PostgreSQL in `CREATE TABLE` statement (#1338) - Thanks @git-hulk
* Support of table function `WITH ORDINALITY` modifier for Postgres (#1337) - Thanks @git-hulk


## [0.48.0] 2024-07-09

Huge shout out to @iffyio @jmhain and @lovasoa for their help reviewing and merging PRs!
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "sqlparser"
description = "Extensible SQL Lexer and Parser with support for ANSI SQL:2011"
version = "0.48.0"
version = "0.51.0"
authors = ["Andy Grove <[email protected]>"]
homepage = "https://github.com/sqlparser-rs/sqlparser-rs"
documentation = "https://docs.rs/sqlparser/"
Expand Down
29 changes: 26 additions & 3 deletions src/ast/data_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ pub enum DataType {
///
/// [hive]: https://docs.cloudera.com/cdw-runtime/cloud/impala-sql-reference/topics/impala-struct.html
/// [bigquery]: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#struct_type
Struct(Vec<StructField>),
Struct(Vec<StructField>, StructBracketKind),
/// Union
///
/// [duckdb]: https://duckdb.org/docs/sql/data_types/union.html
Expand All @@ -319,6 +319,10 @@ pub enum DataType {
/// [`SQLiteDialect`](crate::dialect::SQLiteDialect), from statements such
/// as `CREATE TABLE t1 (a)`.
Unspecified,
/// Trigger data type, returned by functions associated with triggers
///
/// [postgresql]: https://www.postgresql.org/docs/current/plpgsql-trigger.html
Trigger,
}

impl fmt::Display for DataType {
Expand Down Expand Up @@ -513,9 +517,16 @@ impl fmt::Display for DataType {
}
write!(f, ")")
}
DataType::Struct(fields) => {
DataType::Struct(fields, bracket) => {
if !fields.is_empty() {
write!(f, "STRUCT<{}>", display_comma_separated(fields))
match bracket {
StructBracketKind::Parentheses => {
write!(f, "STRUCT({})", display_comma_separated(fields))
}
StructBracketKind::AngleBrackets => {
write!(f, "STRUCT<{}>", display_comma_separated(fields))
}
}
} else {
write!(f, "STRUCT")
}
Expand Down Expand Up @@ -543,6 +554,7 @@ impl fmt::Display for DataType {
write!(f, "Nested({})", display_comma_separated(fields))
}
DataType::Unspecified => Ok(()),
DataType::Trigger => write!(f, "TRIGGER"),
}
}
}
Expand Down Expand Up @@ -613,6 +625,17 @@ fn format_clickhouse_datetime_precision_and_timezone(
Ok(())
}

/// Type of brackets used for `STRUCT` literals.
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
pub enum StructBracketKind {
/// Example: `STRUCT(a INT, b STRING)`
Parentheses,
/// Example: `STRUCT<a INT, b STRING>`
AngleBrackets,
}

/// Timestamp and Time data types information about TimeZone formatting.
///
/// This is more related to a display information than real differences between each variant. To
Expand Down
27 changes: 27 additions & 0 deletions src/ast/dcl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,30 @@ impl fmt::Display for AlterRoleOperation {
}
}
}

/// A `USE` (`Statement::Use`) operation
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
pub enum Use {
Catalog(ObjectName), // e.g. `USE CATALOG foo.bar`
Schema(ObjectName), // e.g. `USE SCHEMA foo.bar`
Database(ObjectName), // e.g. `USE DATABASE foo.bar`
Warehouse(ObjectName), // e.g. `USE WAREHOUSE foo.bar`
Object(ObjectName), // e.g. `USE foo.bar`
Default, // e.g. `USE DEFAULT`
}

impl fmt::Display for Use {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("USE ")?;
match self {
Use::Catalog(name) => write!(f, "CATALOG {}", name),
Use::Schema(name) => write!(f, "SCHEMA {}", name),
Use::Database(name) => write!(f, "DATABASE {}", name),
Use::Warehouse(name) => write!(f, "WAREHOUSE {}", name),
Use::Object(name) => write!(f, "{}", name),
Use::Default => write!(f, "DEFAULT"),
}
}
}
Loading

0 comments on commit f8ad9c1

Please sign in to comment.