Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] merge v0.51.0 #29

Merged
merged 58 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
9108bff
Add support of table function WITH ORDINALITY modifier for Postgre Pa…
git-hulk Jul 9, 2024
993216f
Enable PARTITION BY feature for PostgreSQL while parsing the create t…
git-hulk Jul 13, 2024
20f7ac5
Fix AS query clause should be after the create table options (#1339)
git-hulk Jul 15, 2024
845a1aa
[ClickHouse] Add support for WITH FILL to OrderByExpr (#1330)
nickpresta Jul 20, 2024
028ada8
Support subquery expression in SET expressions (#1343)
iffyio Jul 20, 2024
71dc966
Fix quoted identifier regression edge-case with "from" in SELECT (#1346)
alexander-beedie Jul 21, 2024
48ea564
Support Map literal syntax for DuckDB and Generic (#1344)
goldmedal Jul 21, 2024
b27abf0
Allow to use `()` as the GROUP BY nothing (#1347)
git-hulk Jul 22, 2024
390d4d3
Add support of MATERIALIZED/ALIAS/EPHERMERAL default column options f…
git-hulk Jul 23, 2024
1e82a14
Add CHANGELOG for 0.49.0 (#1350)
alamb Jul 23, 2024
6c64d43
chore: Release sqlparser version 0.49.0
alamb Jul 23, 2024
547d82f
fix CI clippy `1.80` warnings (#1357)
lovasoa Jul 29, 2024
7fdb2ec
Allow to use the TABLE keyword in DESC|DESCRIBE|EXPLAIN TABLE stateme…
git-hulk Jul 29, 2024
c3ba2f3
Snowflake: support position with normal function call syntax (#1341)
jmhain Jul 29, 2024
bc15f7b
Support for postgres String Constants with Unicode Escapes (#1355)
lovasoa Jul 29, 2024
f966580
Allow to use the GLOBAL keyword before the join operator (#1353)
git-hulk Jul 30, 2024
cc13841
Add support of parsing ON CLUSTER in ALTER TABLE for ClickHouse (#1342)
git-hulk Jul 30, 2024
a692ba5
Add support of parsing OPTIMIZE TABLE statement for ClickHouse (#1359)
git-hulk Aug 1, 2024
d49acc6
Parse SETTINGS clause for ClickHouse table-valued functions (#1358)
Jesse-Bakker Aug 1, 2024
8f8c96f
Support parsing empty map literal syntax for DuckDB and Genric (#1361)
goldmedal Aug 4, 2024
a5480ae
Support `Dialect` level precedence, update Postgres `Dialect` to matc…
samuelcolvin Aug 6, 2024
da484c5
Improve comments on `Dialect` (#1366)
alamb Aug 6, 2024
dfb8b81
Add support of ATTACH/DETACH PARTITION for ClickHouse (#1362)
git-hulk Aug 7, 2024
2d4b9b3
Make `Parser::maybe_parse` pub (#1364)
Jesse-Bakker Aug 7, 2024
68a04cd
Update version of GitHub Actions (#1363)
git-hulk Aug 8, 2024
1e209d8
Simplify arrow_cast tests (#1367)
alamb Aug 8, 2024
ca5262c
Use the local GitHub Action to replace setup-rust-action (#1371)
git-hulk Aug 13, 2024
f5b818e
supporting snowflake extract syntax (#1374)
seve-martinez Aug 13, 2024
b072ce2
Adding support for parsing CREATE TRIGGER and DROP TRIGGER statements…
LucaCappelletti94 Aug 14, 2024
c2f46ae
adding support for scale in CEIL and FLOOR functions (#1377)
seve-martinez Aug 14, 2024
6a11a67
Add support of `FREEZE|UNFREEZE PARTITION` syntax for ClickHouse (#1380)
git-hulk Aug 14, 2024
f223530
Simple custom lexical precedence in PostgreSQL dialect (#1379)
samuelcolvin Aug 14, 2024
fab834d
rename `get_next_precedence_full` to `get_next_precedence_default` (#…
samuelcolvin Aug 14, 2024
8c4d30b
Support DuckDB struct syntax and support list of struct syntax (#1372)
jayzhan211 Aug 15, 2024
dd78084
fix: only require `DESCRIBE TABLE` for Snowflake and ClickHouse diale…
alamb Aug 16, 2024
ee2e263
CHANGELOG for 0.50.0 (#1383)
alamb Aug 16, 2024
11a6e6f
chore: Release sqlparser version 0.50.0
alamb Aug 16, 2024
19e694a
Support `ADD PROJECTION` syntax for ClickHouse (#1390)
git-hulk Aug 22, 2024
7282ce2
feat: support different USE statement syntaxes (#1387)
kacpermuda Aug 23, 2024
222b7d1
allow `DateTimeField::Custom` with `EXTRACT` in Postgres (#1394)
samuelcolvin Aug 26, 2024
7b4ac7c
Add support of parsing CLUSTERED BY clause for Hive (#1397)
git-hulk Sep 1, 2024
df86f25
Fix identifier starts with `$` should be regarded as a placeholder in…
git-hulk Sep 1, 2024
d64beea
cleanup `parse_statement` (#1407)
samuelcolvin Sep 1, 2024
4d52ee7
Support create index with clause (#1389)
lewiszlw Sep 1, 2024
1bed87a
Suppor postgres `TRUNCATE` syntax (#1406)
tobyhede Sep 5, 2024
aa714e3
Fix `INTERVAL` parsing to support expressions and units via dialect (…
samuelcolvin Sep 6, 2024
4875dad
fix: Fix stack overflow in parse_subexpr (#1410)
eejbyfeldt Sep 6, 2024
a7b49b5
Add support of `DROP|CLEAR|MATERIALIZE PROJECTION` syntax for ClickHo…
git-hulk Sep 10, 2024
6ba6068
Fix Hive table comment should be after table column definitions (#1413)
git-hulk Sep 10, 2024
8305c5d
minor: Implement common traits for OneOrManyWithParens (#1368)
gstvg Sep 10, 2024
8dbcbb3
minor: Add `databricks` dialect to `dialect_from_str` (#1416)
milenkovicm Sep 10, 2024
cb0c511
Add a test showing how negative constants are parsed (#1421)
alamb Sep 10, 2024
b9e7754
feat: Add support for MSSQL table options (#1414)
bombsimon Sep 11, 2024
70dbb11
CHANGELOG for 0.51.0 (#1422)
alamb Sep 11, 2024
b9f6784
chore: Release sqlparser version 0.51.0
alamb Sep 11, 2024
662717c
Revert @sigma table factor
ayman-sigma Nov 19, 2024
d88ccdb
merge v0.51.0
ayman-sigma Nov 19, 2024
8c31c8d
skip failing test case
ayman-sigma Nov 19, 2024
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
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
Loading