#[non_exhaustive]pub enum ScalarFunctionForm {
PostgreSql,
DuckDb,
TSql,
ClickHouse,
Snowflake,
MySql,
Databricks,
GoogleSql,
Redshift,
Custom(&'static str),
Unsupported(&'static str),
}Expand description
Which scalar-function grammar this engine speaks.
The default is ScalarFunctionForm::PostgreSql, which is what an
unlisted dialect has always been handed. It is a guess and a dangerous one
on a near neighbour: LANGUAGE SQL IMMUTABLE PARALLEL SAFE is a “syntax
error at or near PARALLEL” on Redshift, an engine that descends from
PostgreSQL and reports itself as one. State your form.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
PostgreSql
CREATE FUNCTION … RETURNS … LANGUAGE SQL IMMUTABLE PARALLEL SAFE AS $$…$$ — PostgreSQL, Citus and Razeri’s agnostic renderer.
DuckDb
DuckDB’s CREATE MACRO.
TSql
T-SQL’s scalar UDF.
ClickHouse
ClickHouse’s lambda CREATE FUNCTION … AS (x) -> ….
Snowflake
Snowflake’s UDF.
MySql
MySQL/MariaDB’s CREATE FUNCTION … DETERMINISTIC.
Databricks
Databricks SQL’s UDF.
GoogleSql
GoogleSQL’s CREATE FUNCTION — BigQuery’s.
Redshift
Redshift’s: the volatility is mandatory rather than optional, there is
no PARALLEL SAFE, LANGUAGE follows the body rather than preceding
it, and the body addresses its parameters as $1 and never by name.
Custom(&'static str)
This engine has scalar functions and spells them in a grammar Razeri does not carry. The string is the grammar’s own name.
Your dialect renders the whole CREATE, through
SqlRenderer::render_scalar_function.
Razeri substitutes no near neighbour and refuses nothing; a dialect that
answers Custom without overriding that method has promised a rendering
it does not provide, and the conformance kit reports it.
Unsupported(&'static str)
This engine has no scalar function.
Rare — rare enough that no engine Razeri has measured is one — and the
default was a silent PostgreSql for want of anywhere to say it. The
string is the orientation an author reads: say what this engine offers
instead before saying what it lacks, and name the near form if there is
one.
It is prose that lands inside a SQL comment, so it must never spell a complete statement.