final class MinMax
    implements Scalar, OutputNaming
    uses Snapshot
Public API: explicitly declared with @visibility public.

GREATEST (values) or LEAST (values).

Mirrors PostgreSQL's MinMaxExpr. Rule: PG-MINMAX-001. Facts: the common type of the values (Rules\Expression\Unification); NULL values are ignored, so the NULL rule is PG-COALESCING-NULL-001. The result column is named greatest or least. Source: https://www.postgresql.org/docs/17/functions-conditional.html#FUNCTIONS-GREATEST-LEAST. Status: Implemented.

Naming the result columndoctest
(new \SqlSemantics\Platform\PostgreSql\Statement\Invocation\Conditional\MinMax(\SqlSemantics\Platform\PostgreSql\Statement\Invocation\Conditional\MinMaxKind::Greatest, [new \SqlSemantics\Platform\PostgreSql\Statement\Literal\NullLiteral()]))->outputName()->value // => 'greatest'

Properties§

public non-empty-list<Scalar> $values
public MinMaxKind $kind

Methods§

public function __construct(public MinMaxKind $kind, list<Scalar> $values)

Parameters

$kindMinMaxKindWhich extreme is selected
$valueslist<Scalar>The values in order; at least one
Calls 2
public function outputName(): Name

Names an unaliased result column after the function.

Returns

Test cases 1
Calls 2
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the values, their common type and the NULL fact.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

Calls 6
public function render(Output $out): void

Writes the function keyword with the values.

Parameters

$outOutput
Test cases 1
Calls 1

Test cases 4§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 4

Relations§

Instantiated in 2