Skip to content

Commit 7e0d3a9

Browse files
Merge branch 'main' into no-whitespace-parser
2 parents f5e6209 + effaac5 commit 7e0d3a9

File tree

16 files changed

+374
-24
lines changed

16 files changed

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

changelog/0.60.0.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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.60.0 Changelog
21+
22+
This release consists of 37 commits from 20 contributors. See credits at the end of this changelog for more information.
23+
24+
**Implemented enhancements:**
25+
26+
- feat: Add RESET to the base dialect #2078 [#2079](https://github.com/apache/datafusion-sqlparser-rs/pull/2079) (watford-ep)
27+
- feat: Add support for SET SESSION AUTHORIZATION #2086 [#2087](https://github.com/apache/datafusion-sqlparser-rs/pull/2087) (watford-ep)
28+
29+
**Fixed bugs:**
30+
31+
- fix: parse error on unnamed arg with default syntax [#2091](https://github.com/apache/datafusion-sqlparser-rs/pull/2091) (r1b)
32+
33+
**Other:**
34+
35+
- Add support for INVISIBLE columns in MySQL [#2033](https://github.com/apache/datafusion-sqlparser-rs/pull/2033) (altmannmarcelo)
36+
- Link to actual change logs in CHANGELOG.md [#2040](https://github.com/apache/datafusion-sqlparser-rs/pull/2040) (lovasoa)
37+
- Snowflake: ALTER USER and KeyValueOptions Refactoring [#2035](https://github.com/apache/datafusion-sqlparser-rs/pull/2035) (yoavcloud)
38+
- Correctly tokenize nested comments in Databricks, ClickHouse, and ANSI [#2044](https://github.com/apache/datafusion-sqlparser-rs/pull/2044) (jmhain)
39+
- MySQL: `CREATE INDEX`: allow `USING` clause before `ON` [#2029](https://github.com/apache/datafusion-sqlparser-rs/pull/2029) (MohamedAbdeen21)
40+
- [databricks] update dialect to support grouping by with modifier [#2047](https://github.com/apache/datafusion-sqlparser-rs/pull/2047) (n-young)
41+
- Moved constraint variant outside of `TableConstraint` enum [#2054](https://github.com/apache/datafusion-sqlparser-rs/pull/2054) (LucaCappelletti94)
42+
- Add support for procedure parameter default values [#2041](https://github.com/apache/datafusion-sqlparser-rs/pull/2041) (aharpervc)
43+
- Support updating PRs using github UI [#2052](https://github.com/apache/datafusion-sqlparser-rs/pull/2052) (blaginin)
44+
- Increase version of sqlparser_derive from 0.3.0 to 0.4.0 [#2060](https://github.com/apache/datafusion-sqlparser-rs/pull/2060) (jjbayer)
45+
- Moving several struct variants out of `Statement` enum to allow for trait impls for specific sub-variants [#2057](https://github.com/apache/datafusion-sqlparser-rs/pull/2057) (LucaCappelletti94)
46+
- Added support for SQLite triggers [#2037](https://github.com/apache/datafusion-sqlparser-rs/pull/2037) (LucaCappelletti94)
47+
- Added support for MATCH syntax and unified column option ForeignKey [#2062](https://github.com/apache/datafusion-sqlparser-rs/pull/2062) (LucaCappelletti94)
48+
- chore: add stack overflow warning for Visitor and VisitorMut [#2068](https://github.com/apache/datafusion-sqlparser-rs/pull/2068) (niebayes)
49+
- Reused `CheckConstraint` in `ColumnOption` [#2063](https://github.com/apache/datafusion-sqlparser-rs/pull/2063) (LucaCappelletti94)
50+
- Refactored `ColumnOption::Unique` to reuse `UniqueConstraint` and `PrimaryKeyConstraint` [#2064](https://github.com/apache/datafusion-sqlparser-rs/pull/2064) (LucaCappelletti94)
51+
- Redshift: more copy options [#2072](https://github.com/apache/datafusion-sqlparser-rs/pull/2072) (yoavcloud)
52+
- SQLite: make period optional for CREATE TRIGGER [#2071](https://github.com/apache/datafusion-sqlparser-rs/pull/2071) (takluyver)
53+
- Added TIMESTAMP_NTZ type support with precision to Snowflake dialect [#2080](https://github.com/apache/datafusion-sqlparser-rs/pull/2080) (romanoff)
54+
- Make `BitwiseNot` ("~") available for all dialects, not just PostgreSQL [#2081](https://github.com/apache/datafusion-sqlparser-rs/pull/2081) (alexander-beedie)
55+
- Add snowflake dynamic table parsing [#2083](https://github.com/apache/datafusion-sqlparser-rs/pull/2083) (romanoff)
56+
- Add support for `INSERT INTO VALUE` [#2085](https://github.com/apache/datafusion-sqlparser-rs/pull/2085) (etgarperets)
57+
- Complete PostgreSQL `CREATE TYPE` Support [#2094](https://github.com/apache/datafusion-sqlparser-rs/pull/2094) (LucaCappelletti94)
58+
- Include DML keyword in statement span [#2090](https://github.com/apache/datafusion-sqlparser-rs/pull/2090) (xitep)
59+
- Add PostgreSQL Operator DDL Support [#2096](https://github.com/apache/datafusion-sqlparser-rs/pull/2096) (LucaCappelletti94)
60+
- impl `Spanned` for MERGE statements [#2100](https://github.com/apache/datafusion-sqlparser-rs/pull/2100) (xitep)
61+
- Preserve optional `AS` keyword in aliases [#2103](https://github.com/apache/datafusion-sqlparser-rs/pull/2103) (xitep)
62+
- Added support for `DROP OPERATOR` syntax [#2102](https://github.com/apache/datafusion-sqlparser-rs/pull/2102) (LucaCappelletti94)
63+
- Only set `hive_formats` on `CreateTable` if formats are present [#2105](https://github.com/apache/datafusion-sqlparser-rs/pull/2105) (mvzink)
64+
- Support PostgreSQL C Functions with Multiple AS Parameters [#2095](https://github.com/apache/datafusion-sqlparser-rs/pull/2095) (LucaCappelletti94)
65+
- Added support for `DROP OPERATOR FAMILY` [#2106](https://github.com/apache/datafusion-sqlparser-rs/pull/2106) (LucaCappelletti94)
66+
- Update criterion requirement from 0.7 to 0.8 in /sqlparser_bench [#2111](https://github.com/apache/datafusion-sqlparser-rs/pull/2111) (dependabot[bot])
67+
- Added support for `DROP OPERATOR CLASS` syntax [#2109](https://github.com/apache/datafusion-sqlparser-rs/pull/2109) (LucaCappelletti94)
68+
- Introduce Oracle dialect [#2113](https://github.com/apache/datafusion-sqlparser-rs/pull/2113) (xitep)
69+
70+
## Credits
71+
72+
Thank you to everyone who contributed to this release. Here is a breakdown of commits (PRs merged) per contributor.
73+
74+
```
75+
12 Luca Cappelletti
76+
4 xitep
77+
2 Andriy Romanov
78+
2 Christopher Watford
79+
2 Yoav Cohen
80+
1 Alexander Beedie
81+
1 Andrew Harper
82+
1 Dmitrii Blaginin
83+
1 Joey Hain
84+
1 Joris Bayer
85+
1 Marcelo Altmann
86+
1 Michael Victor Zink
87+
1 Mohamed Abdeen
88+
1 Ophir LOJKINE
89+
1 Thomas Kluyver
90+
1 dependabot[bot]
91+
1 etgarperets
92+
1 nick young
93+
1 niebayes
94+
1 r1b
95+
```
96+
97+
Thank you also to everyone who contributed in other ways such as filing issues, reviewing PRs, and providing feedback on this release.
98+

dev/release/verify-release-candidate.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,15 @@ test_source_distribution() {
124124
cargo build
125125
cargo test --all-features
126126

127-
if ( find -iname 'Cargo.toml' | xargs grep SNAPSHOT ); then
127+
if ( find . -iname 'Cargo.toml' | xargs grep SNAPSHOT ); then
128128
echo "Cargo.toml version should not contain SNAPSHOT for releases"
129129
exit 1
130130
fi
131131

132+
# Can't test using dry-run because sqlparser depends on sqlparser_derive
133+
# see https://github.com/crate-ci/cargo-release/issues/691#issuecomment-2059866021
132134
# Check that publish works
133-
cargo publish --dry-run
135+
# cargo publish --dry-run
134136
}
135137

136138
TEST_SUCCESS=no

examples/cli.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ $ cargo run --example cli - [--dialectname]
5858
"--clickhouse" => Box::new(ClickHouseDialect {}),
5959
"--duckdb" => Box::new(DuckDbDialect {}),
6060
"--sqlite" => Box::new(SQLiteDialect {}),
61+
"--oracle" => Box::new(OracleDialect {}),
6162
"--generic" | "" => Box::new(GenericDialect {}),
6263
s => panic!("Unexpected parameter: {s}"),
6364
};

sqlparser_bench/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ edition = "2018"
2626
sqlparser = { path = "../" }
2727

2828
[dev-dependencies]
29-
criterion = "0.7"
29+
criterion = "0.8"
3030

3131
[[bench]]
3232
name = "sqlparser_bench"

src/ast/ddl.rs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2803,7 +2803,9 @@ impl fmt::Display for CreateTable {
28032803
if let Some(file_format) = self.file_format {
28042804
write!(f, " STORED AS {file_format}")?;
28052805
}
2806-
write!(f, " LOCATION '{}'", self.location.as_ref().unwrap())?;
2806+
if let Some(location) = &self.location {
2807+
write!(f, " LOCATION '{location}'")?;
2808+
}
28072809
}
28082810

28092811
match &self.table_options {
@@ -4288,3 +4290,40 @@ impl Spanned for DropOperatorFamily {
42884290
Span::empty()
42894291
}
42904292
}
4293+
4294+
/// `DROP OPERATOR CLASS` statement
4295+
/// See <https://www.postgresql.org/docs/current/sql-dropopclass.html>
4296+
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
4297+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
4298+
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
4299+
pub struct DropOperatorClass {
4300+
/// `IF EXISTS` clause
4301+
pub if_exists: bool,
4302+
/// One or more operator classes to drop
4303+
pub names: Vec<ObjectName>,
4304+
/// Index method (btree, hash, gist, gin, etc.)
4305+
pub using: Ident,
4306+
/// `CASCADE or RESTRICT`
4307+
pub drop_behavior: Option<DropBehavior>,
4308+
}
4309+
4310+
impl fmt::Display for DropOperatorClass {
4311+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
4312+
write!(f, "DROP OPERATOR CLASS")?;
4313+
if self.if_exists {
4314+
write!(f, " IF EXISTS")?;
4315+
}
4316+
write!(f, " {}", display_comma_separated(&self.names))?;
4317+
write!(f, " USING {}", self.using)?;
4318+
if let Some(drop_behavior) = &self.drop_behavior {
4319+
write!(f, " {}", drop_behavior)?;
4320+
}
4321+
Ok(())
4322+
}
4323+
}
4324+
4325+
impl Spanned for DropOperatorClass {
4326+
fn span(&self) -> Span {
4327+
Span::empty()
4328+
}
4329+
}

src/ast/mod.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub use self::ddl::{
6767
ColumnPolicyProperty, ConstraintCharacteristics, CreateConnector, CreateDomain,
6868
CreateExtension, CreateFunction, CreateIndex, CreateOperator, CreateOperatorClass,
6969
CreateOperatorFamily, CreateTable, CreateTrigger, CreateView, Deduplicate, DeferrableInitial,
70-
DropBehavior, DropExtension, DropFunction, DropOperator, DropOperatorFamily,
70+
DropBehavior, DropExtension, DropFunction, DropOperator, DropOperatorClass, DropOperatorFamily,
7171
DropOperatorSignature, DropTrigger, GeneratedAs, GeneratedExpressionMode, IdentityParameters,
7272
IdentityProperty, IdentityPropertyFormatKind, IdentityPropertyKind, IdentityPropertyOrder,
7373
IndexColumn, IndexOption, IndexType, KeyOrIndexDisplay, Msck, NullsDistinctOption,
@@ -3573,6 +3573,12 @@ pub enum Statement {
35733573
/// <https://www.postgresql.org/docs/current/sql-dropopfamily.html>
35743574
DropOperatorFamily(DropOperatorFamily),
35753575
/// ```sql
3576+
/// DROP OPERATOR CLASS [ IF EXISTS ] name USING index_method [ CASCADE | RESTRICT ]
3577+
/// ```
3578+
/// Note: this is a PostgreSQL-specific statement.
3579+
/// <https://www.postgresql.org/docs/current/sql-dropopclass.html>
3580+
DropOperatorClass(DropOperatorClass),
3581+
/// ```sql
35763582
/// FETCH
35773583
/// ```
35783584
/// Retrieve rows from a query using a cursor
@@ -4803,6 +4809,9 @@ impl fmt::Display for Statement {
48034809
Statement::DropOperatorFamily(drop_operator_family) => {
48044810
write!(f, "{drop_operator_family}")
48054811
}
4812+
Statement::DropOperatorClass(drop_operator_class) => {
4813+
write!(f, "{drop_operator_class}")
4814+
}
48064815
Statement::CreateRole(create_role) => write!(f, "{create_role}"),
48074816
Statement::CreateSecret {
48084817
or_replace,

src/ast/spans.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ impl Spanned for Statement {
370370
Statement::DropExtension(drop_extension) => drop_extension.span(),
371371
Statement::DropOperator(drop_operator) => drop_operator.span(),
372372
Statement::DropOperatorFamily(drop_operator_family) => drop_operator_family.span(),
373+
Statement::DropOperatorClass(drop_operator_class) => drop_operator_class.span(),
373374
Statement::CreateSecret { .. } => Span::empty(),
374375
Statement::CreateServer { .. } => Span::empty(),
375376
Statement::CreateConnector { .. } => Span::empty(),

src/dialect/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ mod generic;
2424
mod hive;
2525
mod mssql;
2626
mod mysql;
27+
mod oracle;
2728
mod postgresql;
2829
mod redshift;
2930
mod snowflake;
@@ -45,6 +46,7 @@ pub use self::generic::GenericDialect;
4546
pub use self::hive::HiveDialect;
4647
pub use self::mssql::MsSqlDialect;
4748
pub use self::mysql::MySqlDialect;
49+
pub use self::oracle::OracleDialect;
4850
pub use self::postgresql::PostgreSqlDialect;
4951
pub use self::redshift::RedshiftSqlDialect;
5052
pub use self::snowflake::SnowflakeDialect;
@@ -1307,6 +1309,7 @@ pub fn dialect_from_str(dialect_name: impl AsRef<str>) -> Option<Box<dyn Dialect
13071309
"ansi" => Some(Box::new(AnsiDialect {})),
13081310
"duckdb" => Some(Box::new(DuckDbDialect {})),
13091311
"databricks" => Some(Box::new(DatabricksDialect {})),
1312+
"oracle" => Some(Box::new(OracleDialect {})),
13101313
_ => None,
13111314
}
13121315
}

src/dialect/oracle.rs

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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+
use super::Dialect;
19+
20+
/// A [`Dialect`] for [Oracle Databases](https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/index.html)
21+
#[derive(Debug)]
22+
pub struct OracleDialect;
23+
24+
impl Dialect for OracleDialect {
25+
// ~ appears not to be called anywhere
26+
fn identifier_quote_style(&self, _identifier: &str) -> Option<char> {
27+
Some('"')
28+
}
29+
30+
fn is_delimited_identifier_start(&self, ch: char) -> bool {
31+
ch == '"'
32+
}
33+
34+
fn is_identifier_start(&self, ch: char) -> bool {
35+
ch.is_alphabetic()
36+
}
37+
38+
fn is_identifier_part(&self, ch: char) -> bool {
39+
ch.is_alphanumeric() || ch == '_' || ch == '$' || ch == '#' || ch == '@'
40+
}
41+
42+
fn supports_outer_join_operator(&self) -> bool {
43+
true
44+
}
45+
46+
fn supports_connect_by(&self) -> bool {
47+
true
48+
}
49+
50+
fn supports_execute_immediate(&self) -> bool {
51+
true
52+
}
53+
54+
fn supports_match_recognize(&self) -> bool {
55+
true
56+
}
57+
58+
fn supports_window_function_null_treatment_arg(&self) -> bool {
59+
true
60+
}
61+
62+
fn supports_boolean_literals(&self) -> bool {
63+
false
64+
}
65+
66+
fn supports_comment_on(&self) -> bool {
67+
true
68+
}
69+
70+
fn supports_create_table_select(&self) -> bool {
71+
true
72+
}
73+
74+
fn supports_set_stmt_without_operator(&self) -> bool {
75+
true
76+
}
77+
78+
fn supports_group_by_expr(&self) -> bool {
79+
true
80+
}
81+
}

0 commit comments

Comments
 (0)