Dialects Reference¶
SQLFluff is designed to be flexible in supporting a variety of dialects. Not all potential dialects are supported so far, but several have been implemented by the community. Below are a list of the currently available dialects. Each inherits from another, up to the root ansi dialect.
For a canonical list of supported dialects, run the sqlfluff dialects command, which will output a list of the current dialects available on your installation of SQLFluff.
Note
For technical users looking to add new dialects or add new features to existing ones, the dependent nature of how dialects have been implemented is to try and reduce the amount of repetition in how different elements are defined. As an example, when we say that the AWS Redshift dialect inherits from the PostgreSQL dialect this is not because there is an agreement between those projects which means that features in one must end up in the other, but that the design of the AWS Redshift dialect was heavily inspired by the postgres dialect and therefore when defining the dialect within sqlfuff it makes sense to use PostgreSQL as a starting point rather than starting from scratch.
Consider when adding new features to a dialect:
Should I be adding it just to this dialect, or adding it to a parent dialect?
If I’m creating a new dialect, which dialect would be best to inherit from?
Will the feature I’m adding break any downstream dependencies within dialects which inherit from this one?
ANSI¶
Label: ansi
Default Casing: UPPERCASE
Quotes: String Literals: ''
, Identifiers: ""
This is the base dialect which holds most of the definitions of common SQL commands and structures. If the dialect which you’re actually using isn’t specifically implemented by SQLFluff, using this dialect is a good place to start.
This dialect doesn’t intend to be brutal in adhering to (and only to) the ANSI SQL spec (mostly because ANSI charges for access to that spec). It aims to be a representation of vanilla SQL before any other project adds their spin to it, and so may contain a slightly wider set of functions than actually available in true ANSI SQL.
AWS Athena¶
Label: athena
Inherits from: ANSI
Default Casing: lowercase
Quotes: String Literals: ''
, ""
or ``
,
Identifiers: ""
or ``
The dialect for Athena on Amazon Web Services (AWS).
Google BigQuery¶
Label: bigquery
Inherits from: ANSI
Default Casing: UPPERCASE
Quotes: String Literals: ''
, ""
, @
or @@
(with the
quoted options, also supporting variants prefixes with r
/R
(for
raw/regex expressions) or b
/B
(for byte strings)),
Identifiers: ""
or ``
. Note that unquoted aliases are
resolved case-insensitively but rendered case-sensitively in the result
set.
The dialect for BigQuery on Google Cloud Platform (GCP).
ClickHouse¶
Label: clickhouse
Inherits from: ANSI
The dialect for ClickHouse.
Databricks¶
Label: databricks
Inherits from: Apache Spark SQL
The dialect for Databricks.
IBM Db2¶
Label: db2
Inherits from: ANSI
The dialect for IBM Db2.
DuckDB¶
Label: duckdb
Inherits from: PostgreSQL
Default Casing: DuckDB stores all identifiers in the case they were defined, however all identifier resolution is case-insensitive (when unquoted, and more unusually, also when quoted). See the DuckDB Identifiers Documentation for more details.
Quotes: String Literals: ''
, Identifiers: ""
or ''
The dialect for DuckDB.
Exasol¶
Label: exasol
Inherits from: ANSI
The dialect for Exasol.
Greenplum¶
Label: greenplum
Inherits from: PostgreSQL
The dialect for Greenplum.
Apache Hive¶
Label: hive
Inherits from: ANSI
The dialect for Apache Hive.
MariaDB¶
Label: mariadb
Inherits from: MySQL
Default Casing: lowercase
Quotes: String Literals: ''
, ""
or @
,
Identifiers: ``
.
The dialect for MariaDB.
Materialize¶
Label: materialize
Inherits from: PostgreSQL
The dialect for Materialize.
MySQL¶
Label: mysql
Inherits from: ANSI
Default Casing: lowercase
Quotes: String Literals: ''
, ""
or @
,
Identifiers: ``
.
The dialect for MySQL.
Oracle¶
Label: oracle
Inherits from: ANSI
The dialect for Oracle SQL. Note: this does not include PL/SQL.
PostgreSQL¶
Label: postgres
Inherits from: ANSI
Default Casing: lowercase
Quotes: String Literals: ''
, Identifiers: ""
.
This is based around the PostgreSQL spec. Many other SQL dialects are often based on the PostreSQL syntax. If you’re running an unsupported dialect, then this is often the dialect to use (until someone makes a specific dialect).
AWS Redshift¶
Label: redshift
Inherits from: PostgreSQL
Default Casing: lowercase
(unless configured
to be case sensitive with all identifiers using the
enable_case_sensitive_identifier
configuration value, see
the Redshift Names & Identifiers Docs).
Quotes: String Literals: ''
, Identifiers: ""
.
The dialect for Redshift on Amazon Web Services (AWS).
Snowflake¶
Label: snowflake
Inherits from: ANSI
Default Casing: UPPERCASE
Quotes: String Literals: ''
, Identifiers: ""
The dialect for Snowflake, which has much of its syntax inherited from PostgreSQL.
Salesforce Object Query Language (SOQL)¶
Label: soql
Inherits from: ANSI
The dialect for SOQL (Salesforce Object Query Language).
Apache Spark SQL¶
Label: sparksql
Inherits from: ANSI
Default Casing: SparkSQL is case insensitive with both quoted and unquoted identifiers (_”delimited”_ identifiers in Spark terminology). See the Spark Identifiers docs.
Quotes: String Literals: ''
or ""
, Identifiers: ``
.
The dialect for Apache Spark SQL. This includes relevant syntax from Apache Hive for commands that permit Hive Format. Spark SQL extensions provided by the Delta Lake project are also implemented in this dialect.
This implementation focuses on the Ansi Compliant Mode introduced in Spark3, instead of being Hive Compliant. The introduction of ANSI Compliance provides better data quality and easier migration from traditional DBMS.
Versions of Spark prior to 3.x will only support the Hive dialect.
SQLite¶
Label: sqlite
Inherits from: ANSI
Default Casing: Not specified in the docs, but through testing it appears that SQLite stores column names in whatever case they were defined, but is always case-insensitive when resolving those names.
Quotes: String Literals: ''
(or ""
if not otherwise resolved
to an identifier), Identifiers: ""
, []
or ``
. See the
SQLite Keywords Docs for more details.
The dialect for SQLite.
Teradata¶
Label: teradata
Inherits from: ANSI
The dialect for Teradata.
Trino¶
Label: trino
Inherits from: ANSI
Default Casing: UPPERCASE
Quotes: String Literals: ''
, Identifiers: ""
The dialect for Trino.
Microsoft T-SQL¶
Label: tsql
Inherits from: ANSI
The dialect for T-SQL (aka Transact-SQL).
Vertica¶
Label: vertica
Inherits from: ANSI
The dialect for Vertica.