sqlparser/dialect/teradata.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 [Teradata](https://docs.teradata.com/).
21#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
22#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
23pub struct TeradataDialect;
24
25impl Dialect for TeradataDialect {
26 /// See <https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/SQL-Fundamentals/Basic-SQL-Syntax/Object-Names>
27 fn identifier_quote_style(&self, _identifier: &str) -> Option<char> {
28 Some('"')
29 }
30
31 /// See <https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/SQL-Fundamentals/Basic-SQL-Syntax/Working-with-Unicode-Delimited-Identifiers>
32 fn is_delimited_identifier_start(&self, ch: char) -> bool {
33 ch == '"'
34 }
35
36 /// See <https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/International-Character-Set-Support/Managing-International-Language-Support/Object-Names/Rules-for-Object-Naming>
37 fn is_identifier_start(&self, ch: char) -> bool {
38 ch.is_alphabetic() || ch == '_' || ch == '#' || ch == '$'
39 }
40
41 // See <https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/SQL-Fundamentals/Basic-SQL-Syntax/Object-Names>
42 fn is_identifier_part(&self, ch: char) -> bool {
43 ch.is_alphanumeric() || self.is_identifier_start(ch)
44 }
45
46 /// See <https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/SQL-Data-Manipulation-Language/SELECT-Statements/GROUP-BY-Clause/GROUP-BY-Clause-Syntax>
47 fn supports_group_by_expr(&self) -> bool {
48 true
49 }
50
51 /// Teradata has no native `BOOLEAN` data type.
52 ///
53 /// See <https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/SQL-Data-Types-and-Literals>
54 fn supports_boolean_literals(&self) -> bool {
55 false
56 }
57
58 /// See <https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/SQL-Data-Types-and-Literals/Data-Literals/Interval-Literals>
59 fn require_interval_qualifier(&self) -> bool {
60 true
61 }
62
63 /// See <https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/SQL-Data-Definition-Language-Syntax-and-Examples/Comment-Help-and-Show-Statements/COMMENT-Comment-Placing-Form>
64 fn supports_comment_on(&self) -> bool {
65 true
66 }
67
68 /// See <https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/SQL-Data-Definition-Language-Syntax-and-Examples/Table-Statements/CREATE-TABLE-and-CREATE-TABLE-AS>
69 fn supports_create_table_select(&self) -> bool {
70 true
71 }
72
73 /// See <https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/SQL-Stored-Procedures-and-Embedded-SQL/Dynamic-Embedded-SQL-Statements/Dynamic-SQL-Statement-Syntax/EXECUTE-IMMEDIATE>
74 fn supports_execute_immediate(&self) -> bool {
75 true
76 }
77
78 /// See <https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/SQL-Data-Manipulation-Language/SELECT-Statements/Select-List-Syntax/TOP-Clause>
79 fn supports_top_before_distinct(&self) -> bool {
80 true
81 }
82
83 /// See <https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/SQL-Functions-Expressions-and-Predicates/Ordered-Analytical/Window-Aggregate-Functions>
84 fn supports_window_function_null_treatment_arg(&self) -> bool {
85 true
86 }
87
88 /// See <https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/SQL-Data-Types-and-Literals/Data-Literals/Character-String-Literals>
89 fn supports_string_literal_concatenation(&self) -> bool {
90 true
91 }
92}