mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-31 19:27:21 +00:00
Add BigQuery dialect (#490)
This commit is contained in:
parent
484a7b6da4
commit
97a148aee4
5 changed files with 127 additions and 1 deletions
35
src/dialect/bigquery.rs
Normal file
35
src/dialect/bigquery.rs
Normal file
|
@ -0,0 +1,35 @@
|
|||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use crate::dialect::Dialect;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct BigQueryDialect;
|
||||
|
||||
impl Dialect for BigQueryDialect {
|
||||
// See https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#identifiers
|
||||
fn is_delimited_identifier_start(&self, ch: char) -> bool {
|
||||
ch == '`'
|
||||
}
|
||||
|
||||
fn is_identifier_start(&self, ch: char) -> bool {
|
||||
('a'..='z').contains(&ch) || ('A'..='Z').contains(&ch) || ch == '_'
|
||||
}
|
||||
|
||||
fn is_identifier_part(&self, ch: char) -> bool {
|
||||
('a'..='z').contains(&ch)
|
||||
|| ('A'..='Z').contains(&ch)
|
||||
|| ('0'..='9').contains(&ch)
|
||||
|| ch == '_'
|
||||
|| ch == '-'
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@
|
|||
// limitations under the License.
|
||||
|
||||
mod ansi;
|
||||
mod bigquery;
|
||||
mod clickhouse;
|
||||
mod generic;
|
||||
mod hive;
|
||||
|
@ -27,6 +28,7 @@ use core::iter::Peekable;
|
|||
use core::str::Chars;
|
||||
|
||||
pub use self::ansi::AnsiDialect;
|
||||
pub use self::bigquery::BigQueryDialect;
|
||||
pub use self::clickhouse::ClickHouseDialect;
|
||||
pub use self::generic::GenericDialect;
|
||||
pub use self::hive::HiveDialect;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue