#[non_exhaustive]pub enum TableFunctionForm {
PostgreSql,
DuckDb,
GoogleSql,
TSql,
ClickHouse,
Snowflake,
Databricks,
Unsupported(&'static str),
Custom(&'static str),
}Expand description
Which table-valued function grammar this engine speaks — the routine a
query selects FROM, returning columns rather than one value.
The default is TableFunctionForm::PostgreSql, which is what an unlisted
dialect has always been handed. Four engines in Razeri’s own set have no
table-valued function they can render, and each says so in its own words
through TableFunctionForm::Unsupported — because a refusal written once
per kind tells a Redshift author about MySQL, and the sentence that
helps is the one about their engine.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
PostgreSql
CREATE FUNCTION … RETURNS TABLE(…) / RETURNS SETOF … over a
dollar-quoted body — PostgreSQL, Citus, and Razeri’s agnostic
renderer.
DuckDb
DuckDB’s table MACRO: CREATE MACRO f(x) AS TABLE SELECT …. There
is no RETURNS clause at all, which is why riding the PostgreSQL arm
was Parser Error: syntax error at or near "RETURNS".
GoogleSql
GoogleSQL’s CREATE TABLE FUNCTION — BigQuery’s.
TSql
T-SQL’s two shapes: the inline TVF (RETURNS TABLE AS RETURN (…)) and
the multi-statement one (RETURNS @t TABLE(…) BEGIN … RETURN END).
ClickHouse
ClickHouse’s parameterized view, addressed with {param:Type}.
Snowflake
Snowflake’s UDTF, including the staged-handler registration.
Databricks
Databricks SQL’s CREATE FUNCTION … RETURNS TABLE … RETURN <query>.
Unsupported(&'static str)
This engine has no table-valued function.
The string is the orientation an author reads — at build time, when
Razeri refuses to write the routine, and again in the rendered refusal
if anything asks the renderer directly. Write it fix-first: say what
this engine offers instead before saying what it lacks, name the
artifact: values a designer would reach for, and name the near form if
there is one, because a near form the author will find on their own is
the thing that costs them a day.
It is prose that lands inside a SQL comment, so it must never spell a complete statement.
Custom(&'static str)
This engine has a table-valued function and spells it in a grammar Razeri does not carry. The string is the grammar’s own name.
Your dialect renders the whole CREATE, through
SqlRenderer::render_table_function.
It is the opposite claim to Unsupported: the
build door writes the routine rather than declining it, because this
engine has one.
Implementations§
Source§impl TableFunctionForm
impl TableFunctionForm
Sourcepub const fn refusal(self) -> Option<&'static str>
pub const fn refusal(self) -> Option<&'static str>
The dialect’s own refusal wording, or None where this engine has the
form.
The one accessor both surfaces read — the build door that declines to write the routine, and the renderer that would otherwise emit DDL — so neither one carries a second copy of the words.
Custom answers None here, and that is the whole
point of it: an engine whose grammar Razeri cannot spell still has a
table-valued function, so the door that asks may I write this at all
gets a yes.
Sourcepub const fn custom_grammar(self) -> Option<&'static str>
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.