Dialects¶
| Dialect | Catalog fetcher | Support |
|---|---|---|
| DuckDB | yes | high, plus the soundness oracle |
| PostgreSQL | yes | low |
MySQL 8.4+ (strict sql_mode) |
yes | low |
| Snowflake | yes | low |
| BigQuery | yes | low |
| Databricks / Spark | yes | low |
| Redshift | yes | low |
| Trino | yes (NOT NULL only) | low |
A low-support dialect has dialect facts written from memory and not yet probed on the engine, so its analysis can contain mistakes: a PROVED assertion there can be wrong. A dialect with no such fact is high support (DuckDB, SQLite); see Support levels.
Every declared key, foreign key and CHECK is trusted, whether or not the engine enforces it: Snowflake, BigQuery, Databricks and Redshift keys prove what they state (see Dialects).
Pass dialect= (a SQLGlot dialect name) to analyze, analyze_database and
suggest. What the analysis assumes of each dialect is in
sqlassert/dialects.py, argued in docs/dialects.md:
- Keys. Every declared primary, unique and foreign key is Knowledge,
whether or not the engine enforces it: Snowflake, BigQuery, Databricks /
Spark, Redshift and Trino keys, SQLite foreign keys, and constraints marked
NOT ENFORCED,NOT VALIDorDEFERRABLEall prove what they state. If the data violates one, the proofs resting on it are wrong. - CHECK constraints.
CHECK (col IN ('a', 'b'))andCHECK (col = v), over literals and joined by AND, state col's Enumerated Domain, as ENUM does (NULL passes a CHECK, and is outside every domain), trusted like keys. Any other CHECK is ignored with anignored-check-constraintwarning. A CHECK read from a catalog means the same, in the form the engine stores it (PostgreSQL'scol = ANY (ARRAY[...]), casts that keep a literal's value). - Text.
VARCHARandTEXTare taken to compare by identity in DuckDB, PostgreSQL and Trino, whose shipped default collation is binary (Trino has no collations); a setting that changes it (DuckDB'sSET default_collation) is out of scope. MySQL's default collations ignore case, and the warehouses are not yet certified, so their text is not. sqlassert supports each dialect's default collation only: aCOLLATEis opaque and warnsunsupported-construct, and a column declared with one is untyped. - Zoned timestamps. A TIMESTAMP WITH TIME ZONE compares by identity where
it holds an instant only (DuckDB, PostgreSQL, MySQL, BigQuery, Spark,
Redshift). Trino and Snowflake keep the zone it was given, so equal instants
cast to different text: there it does not, and comparing a
CASTof one warns (zoned-timestamp-cast). - NULL. Arithmetic and CAST are taken never to return NULL for non-null
operands only where they raise instead (DuckDB, PostgreSQL, BigQuery,
Redshift, Trino, and Spark and Databricks under ANSI mode, their default);
division likewise in PostgreSQL, Snowflake, BigQuery, Redshift, Trino and
Databricks. Spark and Hive may return NULL even from a comparison (a failed
implicit cast). Each engine is modelled at its latest release under its
default settings (ADR 0006). MySQL is modelled
under its default strict
sql_mode, in 8.4 and later: a comparison of non-null operands is non-null, arithmetic is not taken as checked. A CAST from JSON may be NULL everywhere (JSONnull).||andconcat()follow each dialect's NULL handling. - MySQL
||is OR, as under the defaultsql_mode(noPIPES_AS_CONCAT). - Casts. A
CASTkeeps a key, and binds a join key, wherever it keeps different values different: into a wider integer or decimal, into text from an integer, decimal, boolean or date, a DATE into a timestamp, the same type (CAST(id AS TEXT)over a text key). A narrowing cast, text into a number, a float, or a cast into aVARCHAR(n)that truncates (PostgreSQL) keeps none. Implicit casts in a comparison follow the same table. Only DuckDB's entries are probed so far. - Star modifiers.
* EXCLUDE/REPLACE/RENAME(DuckDB, Snowflake),* EXCEPT/REPLACE(BigQuery, ClickHouse) and* EXCEPT(Databricks, Spark) expand into the columns they select. Snowflake'sILIKE, ClickHouse'sAPPLYandCOLUMNS(...)stay opaque and warnunsupported-construct.
Each dialect fact is argued, with its sources and probe results, in docs/dialects.md.