Skip to content

Commit 888201b

Browse files
committed
Merge branch 'main' into eper/snowflake-with-column-options
2 parents 003a643 + b1b379e commit 888201b

16 files changed

Lines changed: 436 additions & 88 deletions

.github/workflows/license.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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: license
19+
20+
# trigger for all PRs and changes to main
21+
on:
22+
push:
23+
branches:
24+
- main
25+
pull_request:
26+
27+
jobs:
28+
29+
rat:
30+
name: Release Audit Tool (RAT)
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v4
34+
- name: Setup Python
35+
uses: actions/setup-python@v5
36+
with:
37+
python-version: 3.8
38+
- name: Audit licenses
39+
run: ./dev/release/run-rat.sh .

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
[package]
1919
name = "sqlparser"
2020
description = "Extensible SQL Lexer and Parser with support for ANSI SQL:2011"
21-
version = "0.56.0"
21+
version = "0.57.0"
2222
authors = ["Apache DataFusion <dev@datafusion.apache.org>"]
2323
homepage = "https://github.com/apache/datafusion-sqlparser-rs"
2424
documentation = "https://docs.rs/sqlparser/"

changelog/0.57.0.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
20+
# sqlparser-rs 0.57.0 Changelog
21+
22+
This release consists of 39 commits from 19 contributors. See credits at the end of this changelog for more information.
23+
24+
**Implemented enhancements:**
25+
26+
- feat: Hive: support `SORT BY` direction [#1873](https://github.com/apache/datafusion-sqlparser-rs/pull/1873) (chenkovsky)
27+
28+
**Other:**
29+
30+
- Support some of pipe operators [#1759](https://github.com/apache/datafusion-sqlparser-rs/pull/1759) (simonvandel)
31+
- Added support for `DROP DOMAIN` [#1828](https://github.com/apache/datafusion-sqlparser-rs/pull/1828) (LucaCappelletti94)
32+
- Improve support for cursors for SQL Server [#1831](https://github.com/apache/datafusion-sqlparser-rs/pull/1831) (aharpervc)
33+
- Add all missing table options to be handled in any order [#1747](https://github.com/apache/datafusion-sqlparser-rs/pull/1747) (benrsatori)
34+
- Add `CREATE TRIGGER` support for SQL Server [#1810](https://github.com/apache/datafusion-sqlparser-rs/pull/1810) (aharpervc)
35+
- Added support for `CREATE DOMAIN` [#1830](https://github.com/apache/datafusion-sqlparser-rs/pull/1830) (LucaCappelletti94)
36+
- Allow stored procedures to be defined without `BEGIN`/`END` [#1834](https://github.com/apache/datafusion-sqlparser-rs/pull/1834) (aharpervc)
37+
- Add support for the MATCH and REGEXP binary operators [#1840](https://github.com/apache/datafusion-sqlparser-rs/pull/1840) (lovasoa)
38+
- Fix: parsing ident starting with underscore in certain dialects [#1835](https://github.com/apache/datafusion-sqlparser-rs/pull/1835) (MohamedAbdeen21)
39+
- implement pretty-printing with `{:#}` [#1847](https://github.com/apache/datafusion-sqlparser-rs/pull/1847) (lovasoa)
40+
- Fix big performance issue in string serialization [#1848](https://github.com/apache/datafusion-sqlparser-rs/pull/1848) (lovasoa)
41+
- Add support for `DENY` statements [#1836](https://github.com/apache/datafusion-sqlparser-rs/pull/1836) (aharpervc)
42+
- Postgresql: Add `REPLICA IDENTITY` operation for `ALTER TABLE` [#1844](https://github.com/apache/datafusion-sqlparser-rs/pull/1844) (MohamedAbdeen21)
43+
- Add support for INCLUDE/EXCLUDE NULLS for UNPIVOT [#1849](https://github.com/apache/datafusion-sqlparser-rs/pull/1849) (Vedin)
44+
- pretty print improvements [#1851](https://github.com/apache/datafusion-sqlparser-rs/pull/1851) (lovasoa)
45+
- fix new rust 1.87 cargo clippy warnings [#1856](https://github.com/apache/datafusion-sqlparser-rs/pull/1856) (lovasoa)
46+
- Update criterion requirement from 0.5 to 0.6 in /sqlparser_bench [#1857](https://github.com/apache/datafusion-sqlparser-rs/pull/1857) (dependabot[bot])
47+
- pretty-print CREATE TABLE statements [#1854](https://github.com/apache/datafusion-sqlparser-rs/pull/1854) (lovasoa)
48+
- pretty-print CREATE VIEW statements [#1855](https://github.com/apache/datafusion-sqlparser-rs/pull/1855) (lovasoa)
49+
- Handle optional datatypes properly in `CREATE FUNCTION` statements [#1826](https://github.com/apache/datafusion-sqlparser-rs/pull/1826) (LucaCappelletti94)
50+
- Mysql: Add `SRID` column option [#1852](https://github.com/apache/datafusion-sqlparser-rs/pull/1852) (MohamedAbdeen21)
51+
- Add support for table valued functions for SQL Server [#1839](https://github.com/apache/datafusion-sqlparser-rs/pull/1839) (aharpervc)
52+
- Keep the COLUMN keyword only if it exists when dropping the column [#1862](https://github.com/apache/datafusion-sqlparser-rs/pull/1862) (git-hulk)
53+
- Add support for parameter default values in SQL Server [#1866](https://github.com/apache/datafusion-sqlparser-rs/pull/1866) (aharpervc)
54+
- Add support for `TABLESAMPLE` pipe operator [#1860](https://github.com/apache/datafusion-sqlparser-rs/pull/1860) (hendrikmakait)
55+
- Adds support for mysql's drop index [#1864](https://github.com/apache/datafusion-sqlparser-rs/pull/1864) (dmzmk)
56+
- Fix: GROUPING SETS accept values without parenthesis [#1867](https://github.com/apache/datafusion-sqlparser-rs/pull/1867) (Vedin)
57+
- Add ICEBERG keyword support to ALTER TABLE statement [#1869](https://github.com/apache/datafusion-sqlparser-rs/pull/1869) (osipovartem)
58+
- MySQL: Support `index_name` in FK constraints [#1871](https://github.com/apache/datafusion-sqlparser-rs/pull/1871) (MohamedAbdeen21)
59+
- Postgres: Apply `ONLY` keyword per table in TRUNCATE stmt [#1872](https://github.com/apache/datafusion-sqlparser-rs/pull/1872) (MohamedAbdeen21)
60+
- Fix `CASE` expression spans [#1874](https://github.com/apache/datafusion-sqlparser-rs/pull/1874) (eliaperantoni)
61+
- MySQL: `[[NOT] ENFORCED]` in CHECK constraint [#1870](https://github.com/apache/datafusion-sqlparser-rs/pull/1870) (MohamedAbdeen21)
62+
- Add support for `CREATE SCHEMA WITH ( <properties> )` [#1877](https://github.com/apache/datafusion-sqlparser-rs/pull/1877) (utay)
63+
- Add support for `ALTER TABLE DROP INDEX` [#1865](https://github.com/apache/datafusion-sqlparser-rs/pull/1865) (vimko)
64+
- chore: Replace archived actions-rs/install action [#1876](https://github.com/apache/datafusion-sqlparser-rs/pull/1876) (assignUser)
65+
- Allow `IF NOT EXISTS` after table name for Snowflake [#1881](https://github.com/apache/datafusion-sqlparser-rs/pull/1881) (bombsimon)
66+
- Support `DISTINCT AS { STRUCT | VALUE }` for BigQuery [#1880](https://github.com/apache/datafusion-sqlparser-rs/pull/1880) (bombsimon)
67+
68+
## Credits
69+
70+
Thank you to everyone who contributed to this release. Here is a breakdown of commits (PRs merged) per contributor.
71+
72+
```
73+
7 Ophir LOJKINE
74+
6 Andrew Harper
75+
6 Mohamed Abdeen
76+
3 Luca Cappelletti
77+
2 Denys Tsomenko
78+
2 Simon Sawert
79+
1 Andrew Lamb
80+
1 Artem Osipov
81+
1 Chen Chongchen
82+
1 Dmitriy Mazurin
83+
1 Elia Perantoni
84+
1 Hendrik Makait
85+
1 Jacob Wujciak-Jens
86+
1 Simon Vandel Sillesen
87+
1 Yannick Utard
88+
1 benrsatori
89+
1 dependabot[bot]
90+
1 hulk
91+
1 vimko
92+
```
93+
94+
Thank you also to everyone who contributed in other ways such as filing issues, reviewing PRs, and providing feedback on this release.
95+

dev/release/rat_exclude_files.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
# Files to exclude from the Apache Rat (license) check
2-
.gitignore
31
.tool-versions
2+
target/*
3+
**.gitignore
4+
rat.txt
45
dev/release/rat_exclude_files.txt
5-
fuzz/.gitignore
66
sqlparser_bench/img/flamegraph.svg
7-
7+
**Cargo.lock
8+
filtered_rat.txt

src/ast/dml.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,9 @@ pub struct CreateTable {
175175
pub partition_by: Option<Box<Expr>>,
176176
/// BigQuery: Table clustering column list.
177177
/// <https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#table_option_list>
178-
pub cluster_by: Option<WrappedCollection<Vec<Ident>>>,
178+
/// Snowflake: Table clustering list which contains base column, expressions on base columns.
179+
/// <https://docs.snowflake.com/en/user-guide/tables-clustering-keys#defining-a-clustering-key-for-a-table>
180+
pub cluster_by: Option<WrappedCollection<Vec<Expr>>>,
179181
/// Hive: Table clustering column list.
180182
/// <https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-CreateTable>
181183
pub clustered_by: Option<ClusteredBy>,

src/ast/helpers/stmt_create_table.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub struct CreateTableBuilder {
9090
pub primary_key: Option<Box<Expr>>,
9191
pub order_by: Option<OneOrManyWithParens<Expr>>,
9292
pub partition_by: Option<Box<Expr>>,
93-
pub cluster_by: Option<WrappedCollection<Vec<Ident>>>,
93+
pub cluster_by: Option<WrappedCollection<Vec<Expr>>>,
9494
pub clustered_by: Option<ClusteredBy>,
9595
pub inherits: Option<Vec<ObjectName>>,
9696
pub strict: bool,
@@ -279,7 +279,7 @@ impl CreateTableBuilder {
279279
self
280280
}
281281

282-
pub fn cluster_by(mut self, cluster_by: Option<WrappedCollection<Vec<Ident>>>) -> Self {
282+
pub fn cluster_by(mut self, cluster_by: Option<WrappedCollection<Vec<Expr>>>) -> Self {
283283
self.cluster_by = cluster_by;
284284
self
285285
}
@@ -542,7 +542,7 @@ impl TryFrom<Statement> for CreateTableBuilder {
542542
#[derive(Default)]
543543
pub(crate) struct CreateTableConfiguration {
544544
pub partition_by: Option<Box<Expr>>,
545-
pub cluster_by: Option<WrappedCollection<Vec<Ident>>>,
545+
pub cluster_by: Option<WrappedCollection<Vec<Expr>>>,
546546
pub inherits: Option<Vec<ObjectName>>,
547547
pub table_options: CreateTableOptions,
548548
}

src/ast/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,14 +428,22 @@ impl fmt::Display for Interval {
428428
pub struct StructField {
429429
pub field_name: Option<Ident>,
430430
pub field_type: DataType,
431+
/// Struct field options.
432+
/// See [BigQuery](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#column_name_and_column_schema)
433+
pub options: Option<Vec<SqlOption>>,
431434
}
432435

433436
impl fmt::Display for StructField {
434437
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
435438
if let Some(name) = &self.field_name {
436-
write!(f, "{name} {}", self.field_type)
439+
write!(f, "{name} {}", self.field_type)?;
437440
} else {
438-
write!(f, "{}", self.field_type)
441+
write!(f, "{}", self.field_type)?;
442+
}
443+
if let Some(options) = &self.options {
444+
write!(f, " OPTIONS({})", display_separated(options, ", "))
445+
} else {
446+
Ok(())
439447
}
440448
}
441449
}

src/ast/query.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3338,22 +3338,28 @@ impl fmt::Display for OpenJsonTableColumn {
33383338
}
33393339

33403340
/// BigQuery supports ValueTables which have 2 modes:
3341-
/// `SELECT AS STRUCT`
3342-
/// `SELECT AS VALUE`
3341+
/// `SELECT [ALL | DISTINCT] AS STRUCT`
3342+
/// `SELECT [ALL | DISTINCT] AS VALUE`
3343+
///
33433344
/// <https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#value_tables>
3345+
/// <https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#select_list>
33443346
#[derive(Debug, Copy, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
33453347
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
33463348
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
33473349
pub enum ValueTableMode {
33483350
AsStruct,
33493351
AsValue,
3352+
DistinctAsStruct,
3353+
DistinctAsValue,
33503354
}
33513355

33523356
impl fmt::Display for ValueTableMode {
33533357
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
33543358
match self {
33553359
ValueTableMode::AsStruct => write!(f, "AS STRUCT"),
33563360
ValueTableMode::AsValue => write!(f, "AS VALUE"),
3361+
ValueTableMode::DistinctAsStruct => write!(f, "DISTINCT AS STRUCT"),
3362+
ValueTableMode::DistinctAsValue => write!(f, "DISTINCT AS VALUE"),
33573363
}
33583364
}
33593365
}

src/dialect/snowflake.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ pub fn parse_create_table(
453453
parser.expect_keyword_is(Keyword::BY)?;
454454
parser.expect_token(&Token::LParen)?;
455455
let cluster_by = Some(WrappedCollection::Parentheses(
456-
parser.parse_comma_separated(|p| p.parse_identifier())?,
456+
parser.parse_comma_separated(|p| p.parse_expr())?,
457457
));
458458
parser.expect_token(&Token::RParen)?;
459459

@@ -560,6 +560,9 @@ pub fn parse_create_table(
560560
builder.storage_serialization_policy =
561561
Some(parse_storage_serialization_policy(parser)?);
562562
}
563+
Keyword::IF if parser.parse_keywords(&[Keyword::NOT, Keyword::EXISTS]) => {
564+
builder = builder.if_not_exists(true);
565+
}
563566
_ => {
564567
return parser.expected("end of statement", next_token);
565568
}

src/display_utils.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
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+
118
//! Utilities for formatting SQL AST nodes with pretty printing support.
219
//!
320
//! The module provides formatters that implement the `Display` trait with support

0 commit comments

Comments
 (0)