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

EXTRACT (field FROM source): a field of a date/time or interval value.

The server calls pg_catalog.extract('field', source). The field is written as a reserved keyword, an identifier or a string constant, and the three spellings are distinct token sequences, so the model keeps which was written. Rule: PG-EXTRACT-001. Facts: those of the call (PG-CALL-RESULT-001; numeric for every date/time source type). The result column is named extract. An identifier field is written quoted when it is spelled like a keyword, because the grammar takes only an identifier there. Source: https://www.postgresql.org/docs/17/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT. Status: Implemented.

Reading the field of an extractiondoctest
$extract = new \SqlSemantics\Platform\PostgreSql\Statement\Invocation\Text\Extract(new \SqlSemantics\Platform\PostgreSql\Model\Statement\Identifier\Name('epoch'), new \SqlSemantics\Platform\PostgreSql\Statement\Literal\NullLiteral());
    [$extract->fieldName(), $extract->outputName()->value] // => ['epoch', 'extract']

Properties§

public Scalar $source

Methods§

public function __construct(
    public ExtractUnit|Name|StringConstant $field,
    public Scalar $source,
)

Parameters

$fieldExtractUnit|Name|StringConstantThe field: a keyword, an identifier or a string constant
$sourceScalarThe value the field is taken from
public function fieldName(): string

Answers the field name the server passes to extract.

Returns

string
Test cases 1
public function outputName(): Name

Names an unaliased result column after the function the server calls.

Returns

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

Derives the source and the result of pg_catalog.extract.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes EXTRACT with the field and the source.

Parameters

$outOutput
Test cases 2
Calls 4

Test cases 6§

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

Dedicated tests 6

Relations§

Instantiated in 1
Type declarations 1