File tree 6 files changed +277
-191
lines changed
6 files changed +277
-191
lines changed Original file line number Diff line number Diff line change @@ -681,6 +681,12 @@ pub trait Dialect: Debug + Any {
681
681
fn supports_partiql ( & self ) -> bool {
682
682
false
683
683
}
684
+
685
+ /// Returns true if the specified keyword is reserved and cannot be
686
+ /// used as an identifier without special handling like quoting.
687
+ fn is_reserved_for_identifier ( & self , kw : Keyword ) -> bool {
688
+ keywords:: RESERVED_FOR_IDENTIFIER . contains ( & kw)
689
+ }
684
690
}
685
691
686
692
/// This represents the operators for which precedence must be defined
Original file line number Diff line number Diff line change @@ -38,6 +38,8 @@ use alloc::vec::Vec;
38
38
#[ cfg( not( feature = "std" ) ) ]
39
39
use alloc:: { format, vec} ;
40
40
41
+ use super :: keywords:: RESERVED_FOR_IDENTIFIER ;
42
+
41
43
/// A [`Dialect`] for [Snowflake](https://www.snowflake.com/)
42
44
#[ derive( Debug , Default ) ]
43
45
pub struct SnowflakeDialect ;
@@ -214,6 +216,16 @@ impl Dialect for SnowflakeDialect {
214
216
fn supports_show_like_before_in ( & self ) -> bool {
215
217
true
216
218
}
219
+
220
+ fn is_reserved_for_identifier ( & self , kw : Keyword ) -> bool {
221
+ // Unreserve some keywords that Snowflake accepts as identifiers
222
+ // See: https://docs.snowflake.com/en/sql-reference/reserved-keywords
223
+ if matches ! ( kw, Keyword :: INTERVAL ) {
224
+ false
225
+ } else {
226
+ RESERVED_FOR_IDENTIFIER . contains ( & kw)
227
+ }
228
+ }
217
229
}
218
230
219
231
/// Parse snowflake create table statement.
Original file line number Diff line number Diff line change @@ -948,3 +948,13 @@ pub const RESERVED_FOR_COLUMN_ALIAS: &[Keyword] = &[
948
948
Keyword :: INTO ,
949
949
Keyword :: END ,
950
950
] ;
951
+
952
+ /// Global list of reserved keywords that cannot be parsed as identifiers
953
+ /// without special handling like quoting. Parser should call `Dialect::is_reserved_for_identifier`
954
+ /// to allow for each dialect to customize the list.
955
+ pub const RESERVED_FOR_IDENTIFIER : & [ Keyword ] = & [
956
+ Keyword :: EXISTS ,
957
+ Keyword :: INTERVAL ,
958
+ Keyword :: STRUCT ,
959
+ Keyword :: TRIM ,
960
+ ] ;
You can’t perform that action at this time.
0 commit comments