Skip to main content

ScalarFunctionForm

Enum ScalarFunctionForm 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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.

Implementations§

Source§

impl ScalarFunctionForm

Source

pub const fn refusal(self) -> Option<&'static str>

The dialect’s own refusal wording, or None where this engine has a scalar function.

Source

pub const fn custom_grammar(self) -> Option<&'static str>

The name of the grammar this dialect renders itself, or None where Razeri renders the function.

Trait Implementations§

Source§

impl Clone for ScalarFunctionForm

Source§

fn clone(&self) -> ScalarFunctionForm

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ScalarFunctionForm

Source§

impl Debug for ScalarFunctionForm

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ScalarFunctionForm

Source§

fn default() -> ScalarFunctionForm

Returns the “default value” for a type. Read more
Source§

impl Eq for ScalarFunctionForm

Source§

impl PartialEq for ScalarFunctionForm

Source§

fn eq(&self, other: &ScalarFunctionForm) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ScalarFunctionForm

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.