Skip to content

Commit c9d67e7

Browse files
committed
Merge
2 parents 8736660 + 15d8bfe commit c9d67e7

25 files changed

+1744
-301
lines changed

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.57.0"
21+
version = "0.58.0"
2222
authors = ["Apache DataFusion <[email protected]>"]
2323
homepage = "https://github.com/apache/datafusion-sqlparser-rs"
2424
documentation = "https://docs.rs/sqlparser/"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
2323
[![Version](https://img.shields.io/crates/v/sqlparser.svg)](https://crates.io/crates/sqlparser)
24-
[![Build Status](https://github.com/sqlparser-rs/sqlparser-rs/workflows/Rust/badge.svg?branch=main)](https://github.com/sqlparser-rs/sqlparser-rs/actions?query=workflow%3ARust+branch%3Amain)
24+
[![Build Status](https://github.com/apache/datafusion-sqlparser-rs/actions/workflows/rust.yml/badge.svg)](https://github.com/sqlparser-rs/sqlparser-rs/actions?query=workflow%3ARust+branch%3Amain)
2525
[![Coverage Status](https://coveralls.io/repos/github/sqlparser-rs/sqlparser-rs/badge.svg?branch=main)](https://coveralls.io/github/sqlparser-rs/sqlparser-rs?branch=main)
2626
[![Gitter Chat](https://badges.gitter.im/sqlparser-rs/community.svg)](https://gitter.im/sqlparser-rs/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
2727

changelog/0.58.0.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
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.58.0 Changelog
21+
22+
This release consists of 47 commits from 18 contributors. See credits at the end of this changelog for more information.
23+
24+
**Fixed bugs:**
25+
26+
- fix: parse snowflake fetch clause [#1894](https://github.com/apache/datafusion-sqlparser-rs/pull/1894) (Vedin)
27+
28+
**Documentation updates:**
29+
30+
- docs: Update rust badge [#1943](https://github.com/apache/datafusion-sqlparser-rs/pull/1943) (Olexandr88)
31+
32+
**Other:**
33+
34+
- Add license header check to CI [#1888](https://github.com/apache/datafusion-sqlparser-rs/pull/1888) (alamb)
35+
- Add support of parsing struct field's options in BigQuery [#1890](https://github.com/apache/datafusion-sqlparser-rs/pull/1890) (git-hulk)
36+
- Fix parsing error when having fields after nested struct in BigQuery [#1897](https://github.com/apache/datafusion-sqlparser-rs/pull/1897) (git-hulk)
37+
- Extend exception handling [#1884](https://github.com/apache/datafusion-sqlparser-rs/pull/1884) (bombsimon)
38+
- Postgres: Add support for text search types [#1889](https://github.com/apache/datafusion-sqlparser-rs/pull/1889) (MohamedAbdeen21)
39+
- Fix `limit` in subqueries [#1899](https://github.com/apache/datafusion-sqlparser-rs/pull/1899) (Dimchikkk)
40+
- Use `IndexColumn` in all index definitions [#1900](https://github.com/apache/datafusion-sqlparser-rs/pull/1900) (mvzink)
41+
- Support procedure argmode [#1901](https://github.com/apache/datafusion-sqlparser-rs/pull/1901) (ZacJW)
42+
- Fix `impl Ord for Ident` [#1893](https://github.com/apache/datafusion-sqlparser-rs/pull/1893) (eliaperantoni)
43+
- Snowflake: support multiple column options in `CREATE VIEW` [#1891](https://github.com/apache/datafusion-sqlparser-rs/pull/1891) (eliaperantoni)
44+
- Add support for `LANGUAGE` clause in `CREATE PROCEDURE` [#1903](https://github.com/apache/datafusion-sqlparser-rs/pull/1903) (ZacJW)
45+
- Fix clippy lints on 1.88.0 [#1910](https://github.com/apache/datafusion-sqlparser-rs/pull/1910) (iffyio)
46+
- Snowflake: Add support for future grants [#1906](https://github.com/apache/datafusion-sqlparser-rs/pull/1906) (yoavcloud)
47+
- Support for Map values in ClickHouse settings [#1896](https://github.com/apache/datafusion-sqlparser-rs/pull/1896) (solontsev)
48+
- Fix join precedence for non-snowflake queries [#1905](https://github.com/apache/datafusion-sqlparser-rs/pull/1905) (Dimchikkk)
49+
- Support remaining pipe operators [#1879](https://github.com/apache/datafusion-sqlparser-rs/pull/1879) (simonvandel)
50+
- Make `GenericDialect` support from-first syntax [#1911](https://github.com/apache/datafusion-sqlparser-rs/pull/1911) (simonvandel)
51+
- Redshift utf8 idents [#1915](https://github.com/apache/datafusion-sqlparser-rs/pull/1915) (yoavcloud)
52+
- DuckDB: Add support for multiple `TRIM` arguments [#1916](https://github.com/apache/datafusion-sqlparser-rs/pull/1916) (ryanschneider)
53+
- Redshift alter column type no set [#1912](https://github.com/apache/datafusion-sqlparser-rs/pull/1912) (yoavcloud)
54+
- Postgres: support `ADD CONSTRAINT NOT VALID` and `VALIDATE CONSTRAINT` [#1908](https://github.com/apache/datafusion-sqlparser-rs/pull/1908) (achristmascarl)
55+
- Add support for MySQL MEMBER OF [#1917](https://github.com/apache/datafusion-sqlparser-rs/pull/1917) (yoavcloud)
56+
- Add span for `Expr::TypedString` [#1919](https://github.com/apache/datafusion-sqlparser-rs/pull/1919) (feral-dot-io)
57+
- Support for Postgres `CREATE SERVER` [#1914](https://github.com/apache/datafusion-sqlparser-rs/pull/1914) (solontsev)
58+
- Change tag and policy names to `ObjectName` [#1892](https://github.com/apache/datafusion-sqlparser-rs/pull/1892) (eliaperantoni)
59+
- Add support for NULL escape char in pattern match searches [#1913](https://github.com/apache/datafusion-sqlparser-rs/pull/1913) (yoavcloud)
60+
- Add support for dropping multiple columns in Snowflake [#1918](https://github.com/apache/datafusion-sqlparser-rs/pull/1918) (yoavcloud)
61+
- Align Snowflake dialect to new test of reserved keywords [#1924](https://github.com/apache/datafusion-sqlparser-rs/pull/1924) (yoavcloud)
62+
- Make `GenericDialect` support trailing commas in projections [#1921](https://github.com/apache/datafusion-sqlparser-rs/pull/1921) (simonvandel)
63+
- Add support for several Snowflake grant statements [#1922](https://github.com/apache/datafusion-sqlparser-rs/pull/1922) (yoavcloud)
64+
- Clickhouse: support empty parenthesized options [#1925](https://github.com/apache/datafusion-sqlparser-rs/pull/1925) (solontsev)
65+
- Add Snowflake `COPY/REVOKE CURRENT GRANTS` option [#1926](https://github.com/apache/datafusion-sqlparser-rs/pull/1926) (yoavcloud)
66+
- Add support for Snowflake identifier function [#1929](https://github.com/apache/datafusion-sqlparser-rs/pull/1929) (yoavcloud)
67+
- Add support for granting privileges to procedures and functions in Snowflake [#1930](https://github.com/apache/datafusion-sqlparser-rs/pull/1930) (yoavcloud)
68+
- Add support for `+` char in Snowflake stage names [#1935](https://github.com/apache/datafusion-sqlparser-rs/pull/1935) (yoavcloud)
69+
- Snowflake Reserved SQL Keywords as Implicit Table Alias [#1934](https://github.com/apache/datafusion-sqlparser-rs/pull/1934) (yoavcloud)
70+
- Add support for Redshift `SELECT * EXCLUDE` [#1936](https://github.com/apache/datafusion-sqlparser-rs/pull/1936) (yoavcloud)
71+
- Support optional semicolon between statements [#1937](https://github.com/apache/datafusion-sqlparser-rs/pull/1937) (yoavcloud)
72+
- Snowflake: support trailing options in `CREATE TABLE` [#1931](https://github.com/apache/datafusion-sqlparser-rs/pull/1931) (yoavcloud)
73+
- MSSQL: Add support for EXEC output and default keywords [#1940](https://github.com/apache/datafusion-sqlparser-rs/pull/1940) (yoavcloud)
74+
- Add identifier unicode support in Mysql, Postgres and Redshift [#1933](https://github.com/apache/datafusion-sqlparser-rs/pull/1933) (etgarperets)
75+
- Add identifier start unicode support for Postegres, MySql and Redshift [#1944](https://github.com/apache/datafusion-sqlparser-rs/pull/1944) (etgarperets)
76+
- Fix for Postgres regex and like binary operators [#1928](https://github.com/apache/datafusion-sqlparser-rs/pull/1928) (solontsev)
77+
- Snowflake: Improve accuracy of lookahead in implicit LIMIT alias [#1941](https://github.com/apache/datafusion-sqlparser-rs/pull/1941) (yoavcloud)
78+
- Add support for `DROP USER` statement [#1951](https://github.com/apache/datafusion-sqlparser-rs/pull/1951) (yoavcloud)
79+
80+
## Credits
81+
82+
Thank you to everyone who contributed to this release. Here is a breakdown of commits (PRs merged) per contributor.
83+
84+
```
85+
19 Yoav Cohen
86+
4 Sergey Olontsev
87+
3 Elia Perantoni
88+
3 Simon Vandel Sillesen
89+
2 Dima
90+
2 ZacJW
91+
2 etgarperets
92+
2 hulk
93+
1 Andrew Lamb
94+
1 Denys Tsomenko
95+
1 Ifeanyi Ubah
96+
1 Michael Victor Zink
97+
1 Mohamed Abdeen
98+
1 Olexandr88
99+
1 Ryan Schneider
100+
1 Simon Sawert
101+
1 carl
102+
1 feral-dot-io
103+
```
104+
105+
Thank you also to everyone who contributed in other ways such as filing issues, reviewing PRs, and providing feedback on this release.
106+

src/ast/ddl.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ pub enum AlterTableOperation {
149149
},
150150
/// `ATTACH PART|PARTITION <partition_expr>`
151151
/// Note: this is a ClickHouse-specific operation, please refer to
152-
/// [ClickHouse](https://clickhouse.com/docs/en/sql-reference/statements/alter/pakrtition#attach-partitionpart)
152+
/// [ClickHouse](https://clickhouse.com/docs/en/sql-reference/statements/alter/partition#attach-partitionpart)
153153
AttachPartition {
154154
// PART is not a short form of PARTITION, it's a separate keyword
155155
// which represents a physical file on disk and partition is a logical entity.
@@ -351,6 +351,16 @@ pub enum AlterTableOperation {
351351
ValidateConstraint {
352352
name: Ident,
353353
},
354+
/// Arbitrary parenthesized `SET` options.
355+
///
356+
/// Example:
357+
/// ```sql
358+
/// SET (scale_factor = 0.01, threshold = 500)`
359+
/// ```
360+
/// [PostgreSQL](https://www.postgresql.org/docs/current/sql-altertable.html)
361+
SetOptionsParens {
362+
options: Vec<SqlOption>,
363+
},
354364
}
355365

356366
/// An `ALTER Policy` (`Statement::AlterPolicy`) operation
@@ -791,6 +801,9 @@ impl fmt::Display for AlterTableOperation {
791801
AlterTableOperation::ValidateConstraint { name } => {
792802
write!(f, "VALIDATE CONSTRAINT {name}")
793803
}
804+
AlterTableOperation::SetOptionsParens { options } => {
805+
write!(f, "SET ({})", display_comma_separated(options))
806+
}
794807
}
795808
}
796809
}

src/ast/helpers/key_value_options.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,22 @@ use serde::{Deserialize, Serialize};
3131
#[cfg(feature = "visitor")]
3232
use sqlparser_derive::{Visit, VisitMut};
3333

34+
use crate::ast::display_separated;
35+
3436
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
3537
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
3638
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
3739
pub struct KeyValueOptions {
3840
pub options: Vec<KeyValueOption>,
41+
pub delimiter: KeyValueOptionsDelimiter,
42+
}
43+
44+
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
45+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
46+
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
47+
pub enum KeyValueOptionsDelimiter {
48+
Space,
49+
Comma,
3950
}
4051

4152
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
@@ -59,18 +70,11 @@ pub struct KeyValueOption {
5970

6071
impl fmt::Display for KeyValueOptions {
6172
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
62-
if !self.options.is_empty() {
63-
let mut first = false;
64-
for option in &self.options {
65-
if !first {
66-
first = true;
67-
} else {
68-
f.write_str(" ")?;
69-
}
70-
write!(f, "{option}")?;
71-
}
72-
}
73-
Ok(())
73+
let sep = match self.delimiter {
74+
KeyValueOptionsDelimiter::Space => " ",
75+
KeyValueOptionsDelimiter::Comma => ", ",
76+
};
77+
write!(f, "{}", display_separated(&self.options, sep))
7478
}
7579
}
7680

src/ast/helpers/stmt_create_table.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,26 @@ impl CreateTableBuilder {
383383
self
384384
}
385385

386+
/// Returns true if the statement has exactly one source of info on the schema of the new table.
387+
/// This is Snowflake-specific, some dialects allow more than one source.
388+
pub(crate) fn validate_schema_info(&self) -> bool {
389+
let mut sources = 0;
390+
if !self.columns.is_empty() {
391+
sources += 1;
392+
}
393+
if self.query.is_some() {
394+
sources += 1;
395+
}
396+
if self.like.is_some() {
397+
sources += 1;
398+
}
399+
if self.clone.is_some() {
400+
sources += 1;
401+
}
402+
403+
sources == 1
404+
}
405+
386406
pub fn build(self) -> Statement {
387407
Statement::CreateTable(CreateTable {
388408
or_replace: self.or_replace,

0 commit comments

Comments
 (0)