sqltk_parser/dialect/
bigquery.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 [Google Bigquery](https://cloud.google.com/bigquery/)
21#[derive(Debug, Default)]
22pub struct BigQueryDialect;
23
24impl Dialect for BigQueryDialect {
25    // See https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#identifiers
26    fn is_delimited_identifier_start(&self, ch: char) -> bool {
27        ch == '`'
28    }
29
30    fn supports_projection_trailing_commas(&self) -> bool {
31        true
32    }
33
34    fn is_identifier_start(&self, ch: char) -> bool {
35        ch.is_ascii_lowercase() || ch.is_ascii_uppercase() || ch == '_'
36    }
37
38    fn is_identifier_part(&self, ch: char) -> bool {
39        ch.is_ascii_lowercase() || ch.is_ascii_uppercase() || ch.is_ascii_digit() || ch == '_'
40    }
41
42    /// See [doc](https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#quoted_literals)
43    fn supports_triple_quoted_string(&self) -> bool {
44        true
45    }
46
47    /// See [doc](https://cloud.google.com/bigquery/docs/reference/standard-sql/navigation_functions#first_value)
48    fn supports_window_function_null_treatment_arg(&self) -> bool {
49        true
50    }
51
52    // See https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#escape_sequences
53    fn supports_string_literal_backslash_escape(&self) -> bool {
54        true
55    }
56
57    /// See [doc](https://cloud.google.com/bigquery/docs/reference/standard-sql/window-function-calls#ref_named_window)
58    fn supports_window_clause_named_window_reference(&self) -> bool {
59        true
60    }
61
62    /// See [doc](https://cloud.google.com/bigquery/docs/reference/standard-sql/procedural-language#set)
63    fn supports_parenthesized_set_variables(&self) -> bool {
64        true
65    }
66
67    // See https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#select_except
68    fn supports_select_wildcard_except(&self) -> bool {
69        true
70    }
71
72    fn require_interval_qualifier(&self) -> bool {
73        true
74    }
75
76    // See https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#constructing_a_struct
77    fn supports_struct_literal(&self) -> bool {
78        true
79    }
80}