Thanks to visit codestin.com
Credit goes to docs.rs

sqlparser/dialect/
databricks.rs

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
18use crate::dialect::Dialect;
19
20/// A [`Dialect`] for [Databricks SQL](https://www.databricks.com/)
21///
22/// See <https://docs.databricks.com/en/sql/language-manual/index.html>.
23#[derive(Debug, Default)]
24pub struct DatabricksDialect;
25
26impl Dialect for DatabricksDialect {
27    // see https://docs.databricks.com/en/sql/language-manual/sql-ref-identifiers.html
28
29    fn is_delimited_identifier_start(&self, ch: char) -> bool {
30        matches!(ch, '`')
31    }
32
33    fn is_identifier_start(&self, ch: char) -> bool {
34        matches!(ch, 'a'..='z' | 'A'..='Z' | '_')
35    }
36
37    fn is_identifier_part(&self, ch: char) -> bool {
38        matches!(ch, 'a'..='z' | 'A'..='Z' | '0'..='9' | '_')
39    }
40
41    fn supports_filter_during_aggregation(&self) -> bool {
42        true
43    }
44
45    // https://docs.databricks.com/en/sql/language-manual/sql-ref-syntax-qry-select-groupby.html
46    fn supports_group_by_expr(&self) -> bool {
47        true
48    }
49
50    fn supports_lambda_functions(&self) -> bool {
51        true
52    }
53
54    // https://docs.databricks.com/en/sql/language-manual/sql-ref-syntax-qry-select.html#syntax
55    fn supports_select_wildcard_except(&self) -> bool {
56        true
57    }
58
59    fn require_interval_qualifier(&self) -> bool {
60        true
61    }
62
63    // See https://docs.databricks.com/en/sql/language-manual/functions/struct.html
64    fn supports_struct_literal(&self) -> bool {
65        true
66    }
67}