Skip to main content

Module registry

Module registry 

Source
Expand description

Registry of the declared properties of every scalar function variant.

The stable LIR schema (see lir_schema.rs in mz-compute-types) pins the shape of UnaryFunc, BinaryFunc and VariadicFunc: their variants and payloads. It cannot see the properties the optimizer and the renderer rely on, such as null propagation, error behavior, monotonicity and output typing, nor the function bodies themselves. A change to any of those changes the meaning of a stored LIR plan without changing its serialized form.

FuncRegistry::build records those properties for one representative instance of every variant, and tests/func_registry.rs in mz-compute-types compares the result against checked-in snapshots, one per half of Record. The module exists only under the func-registry feature, which that test enables. Production builds carry none of it. For #[sqlfunc] functions the record also carries the declaration text, the types-only signature and a fingerprint of the function body, see SqlFuncSource, and the output type is probed at the column types the parameter types map to, see ColumnTypeProbe.

Variants whose payload cannot be constructed without data need a representative Sample in this module. Building the registry panics and names the variant otherwise. Samples may also be given for a constructible variant, to probe its output type at chosen input types or to record payloads whose properties differ, see Sample.

StructsΒ§

BinaryFuncProperties
ColumnTypeProbe
Resolves a Rust parameter type to its column type by autoref specialization: (&ColumnTypeProbe::<T>(PhantomData)).column_type() picks ProbeColumnType when T: AsColumnType and ProbeColumnTypeFallback otherwise. #[sqlfunc] emits that expression for each parameter, which is how it can ask for a column type without knowing whether one exists.
FuncRegistry
The registry of every variant of the three scalar function enums, keyed by canonical variant name (see FuncName) as described on Sample.
FuncSource
Where a record’s properties came from.
Record
One registry entry: the properties that decide what a stored plan using the function computes, and the source they were read from.
Sample
A representative instance of a function variant.
UnaryFuncProperties
VariadicFuncProperties

TraitsΒ§

ProbeColumnType
The specialized arm of ColumnTypeProbe.
ProbeColumnTypeFallback
The fallback arm of ColumnTypeProbe, reached through one more autoref than ProbeColumnType so it only applies when that one does not.

FunctionsΒ§

array_type πŸ”’
binary πŸ”’
binary_samples πŸ”’
collect πŸ”’
Records the properties of every variant of one function enum, keyed as described on Sample.
column πŸ”’
list_type πŸ”’
map_type πŸ”’
numeric_cast_samples πŸ”’
The numeric casts, each without a scale (the primary record) and with one. Only the scaled cast can error, because it rounds.
payload_has_fields πŸ”’
Whether a variant’s payload struct has any fields.
probe πŸ”’
Runs properties on a sample, attributing any panic (typically an output_sql_type impl rejecting the sample’s input types) to the sample.
range_type πŸ”’
record_type πŸ”’
regex πŸ”’
type_strings πŸ”’
unary πŸ”’
unary_samples πŸ”’
variadic πŸ”’
variadic_samples πŸ”’
variant_ident πŸ”’
The serde variant name, which is what the stable LIR format stores.