File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // Licensed under the Apache License, Version 2.0 (the "License");
2+ // you may not use this file except in compliance with the License.
3+ // You may obtain a copy of the License at
4+ //
5+ // http://www.apache.org/licenses/LICENSE-2.0
6+ //
7+ // Unless required by applicable law or agreed to in writing, software
8+ // distributed under the License is distributed on an "AS IS" BASIS,
9+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+ // See the License for the specific language governing permissions and
11+ // limitations under the License.
12+
13+ use crate :: dialect:: Dialect ;
14+
15+ #[ derive( Debug ) ]
16+ pub struct DatabricksDialect { }
17+
18+ // derived from AnsiDialect, but modified with backtick identifier
19+ impl Dialect for DatabricksDialect {
20+ fn is_identifier_start ( & self , ch : char ) -> bool {
21+ ( 'a' ..='z' ) . contains ( & ch) || ( 'A' ..='Z' ) . contains ( & ch)
22+ }
23+
24+ fn is_identifier_part ( & self , ch : char ) -> bool {
25+ ( 'a' ..='z' ) . contains ( & ch)
26+ || ( 'A' ..='Z' ) . contains ( & ch)
27+ || ( '0' ..='9' ) . contains ( & ch)
28+ || ch == '_'
29+ }
30+
31+ fn is_delimited_identifier_start ( & self , ch : char ) -> bool {
32+ ch == '`'
33+ }
34+ }
Original file line number Diff line number Diff line change 1212
1313mod ansi;
1414mod bigquery;
15+ mod databricks;
1516mod generic;
1617pub mod keywords;
1718mod mssql;
@@ -25,6 +26,7 @@ use std::fmt::Debug;
2526
2627pub use self :: ansi:: AnsiDialect ;
2728pub use self :: bigquery:: BigQueryDialect ;
29+ pub use self :: databricks:: DatabricksDialect ;
2830pub use self :: generic:: GenericDialect ;
2931pub use self :: mssql:: MsSqlDialect ;
3032pub use self :: mysql:: MySqlDialect ;
Original file line number Diff line number Diff line change @@ -2072,7 +2072,10 @@ impl<'a> Parser<'a> {
20722072 // ignore the <separator> and treat the multiple strings as
20732073 // a single <literal>."
20742074 Token :: SingleQuotedString ( s) => Ok ( Some ( Ident :: with_quote ( '\'' , s) ) ) ,
2075- Token :: BacktickQuotedString ( s) if dialect_of ! ( self is BigQueryDialect ) => {
2075+ Token :: BacktickQuotedString ( s)
2076+ if dialect_of ! ( self is BigQueryDialect )
2077+ || dialect_of ! ( self is DatabricksDialect ) =>
2078+ {
20762079 Ok ( Some ( Ident :: with_quote ( '`' , s) ) )
20772080 }
20782081 not_an_ident => {
You can’t perform that action at this time.
0 commit comments