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.
1718use crate::dialect::Dialect;
1920/// A [`Dialect`] for [DuckDB](https://duckdb.org/)
21#[derive(#[automatically_derived]
impl ::core::fmt::Debug for DuckDbDialect {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f, "DuckDbDialect")
}
}Debug, #[automatically_derived]
impl ::core::default::Default for DuckDbDialect {
#[inline]
fn default() -> DuckDbDialect { DuckDbDialect {} }
}Default, #[automatically_derived]
impl ::core::clone::Clone for DuckDbDialect {
#[inline]
fn clone(&self) -> DuckDbDialect { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for DuckDbDialect { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for DuckDbDialect {
#[inline]
fn eq(&self, other: &DuckDbDialect) -> bool { true }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for DuckDbDialect {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for DuckDbDialect {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {}
}Hash, #[automatically_derived]
impl ::core::cmp::PartialOrd for DuckDbDialect {
#[inline]
fn partial_cmp(&self, other: &DuckDbDialect)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::option::Option::Some(::core::cmp::Ordering::Equal)
}
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for DuckDbDialect {
#[inline]
fn cmp(&self, other: &DuckDbDialect) -> ::core::cmp::Ordering {
::core::cmp::Ordering::Equal
}
}Ord)]
22#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
23pub struct DuckDbDialect;
2425// In most cases the redshift dialect is identical to [`PostgresSqlDialect`].
26impl Dialectfor DuckDbDialect {
27fn supports_trailing_commas(&self) -> bool {
28true
29}
3031fn is_identifier_start(&self, ch: char) -> bool {
32ch.is_alphabetic() || ch == '_'
33}
3435fn is_identifier_part(&self, ch: char) -> bool {
36ch.is_alphabetic() || ch.is_ascii_digit() || ch == '$' || ch == '_'
37}
3839fn supports_filter_during_aggregation(&self) -> bool {
40true
41}
4243fn supports_group_by_expr(&self) -> bool {
44true
45}
4647fn supports_bitwise_shift_operators(&self) -> bool {
48true
49}
5051fn supports_named_fn_args_with_eq_operator(&self) -> bool {
52true
53}
5455fn supports_named_fn_args_with_assignment_operator(&self) -> bool {
56true
57}
5859// DuckDB uses this syntax for `STRUCT`s.
60 //
61 // https://duckdb.org/docs/sql/data_types/struct.html#creating-structs
62fn supports_dictionary_syntax(&self) -> bool {
63true
64}
6566// DuckDB uses this syntax for `MAP`s.
67 //
68 // https://duckdb.org/docs/sql/data_types/map.html#creating-maps
69fn support_map_literal_syntax(&self) -> bool {
70true
71}
7273/// See <https://duckdb.org/docs/stable/sql/functions/lambda>
74fn supports_lambda_functions(&self) -> bool {
75true
76}
7778/// Returns true if this dialect allows the `EXTRACT` function to use single quotes in the part being extracted.
79fn allow_extract_single_quotes(&self) -> bool {
80true
81}
8283// DuckDB is compatible with PostgreSQL syntax for this statement,
84 // although not all features may be implemented.
85fn supports_explain_with_utility_options(&self) -> bool {
86true
87}
8889/// See DuckDB <https://duckdb.org/docs/sql/statements/load_and_install.html#load>
90fn supports_load_extension(&self) -> bool {
91true
92}
9394// See DuckDB <https://duckdb.org/docs/sql/data_types/array.html#defining-an-array-field>
95fn supports_array_typedef_with_brackets(&self) -> bool {
96true
97}
9899fn supports_from_first_select(&self) -> bool {
100true
101}
102103/// See DuckDB <https://duckdb.org/docs/sql/query_syntax/orderby.html#order-by-all-examples>
104fn supports_order_by_all(&self) -> bool {
105true
106}
107108fn supports_select_wildcard_exclude(&self) -> bool {
109true
110}
111112/// DuckDB supports `NOTNULL` as an alias for `IS NOT NULL`,
113 /// see DuckDB Comparisons <https://duckdb.org/docs/stable/sql/expressions/comparison_operators#between-and-is-not-null>
114fn supports_notnull_operator(&self) -> bool {
115true
116}
117118/// See <https://duckdb.org/docs/extensions/overview>
119fn supports_install(&self) -> bool {
120true
121}
122123/// See <https://duckdb.org/docs/sql/statements/attach#detach-syntax>
124fn supports_detach(&self) -> bool {
125true
126}
127128/// See <https://duckdb.org/docs/sql/query_syntax/select#replace-clause>
129fn supports_select_wildcard_replace(&self) -> bool {
130true
131}
132}