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

A call of EXTRACT(unit FROM date): the part of a date or time a unit names.

Rule: MYSQL-EXTRACT-CALL-001. The result is an integer; it is NULL when the argument is NULL or not a valid date or time. Terminates: the operand is a strict part. Source: https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_extract. Status: Implemented.

Typing EXTRACT()doctest
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze("SELECT EXTRACT(YEAR_MONTH FROM '2024-07-02')");
    $query->field(0)->type->descriptor->name() // => 'BIGINT'

Properties§

public Scalar $source

Methods§

public function __construct(public IntervalUnit $unit, public Scalar $source)

Parameters

$unitIntervalUnitThe part to extract
$sourceScalarThe date or time
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the operand; the result is an integer.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes the call.

Parameters

$outOutput
Test cases 1
Calls 1

Test cases 3§

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

Dedicated tests 2
Other tests reaching this symbol 1

Relations§

Instantiated in 1