final class XmlTable
    implements Relation
    uses Snapshot
Public API: explicitly declared with @visibility public.

XMLTABLE as a FROM item: rows and columns read from an XML value.

Mirrors PostgreSQL's RangeTableFunc. The facts follow PG-XMLTABLE-001. Like a function call, it may refer to the FROM items before it whether or not LATERAL is written; the word is kept as written. Source: https://www.postgresql.org/docs/17/functions-xml.html#FUNCTIONS-XML-PROCESSING-XMLTABLE. Status: Implemented.

Reading the columns of XMLTABLEdoctest
$query = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze("SELECT * FROM XMLTABLE ('/r' PASSING '<r/>' COLUMNS n FOR ORDINALITY, a text PATH 'a' NOT NULL) AS x");
    [$query->field(0)->type->descriptor->name(), $query->field(1)->nullability->name] // => ['integer', 'NotNull']

Properties§

public list<XmlNamespace> $namespaces
public non-empty-list<XmlTableColumn> $columns
public list<Name> $aliases
public Scalar $row
public Clause $passing
public Name|null $alias = null
public bool $lateral = false

Methods§

public function __construct(
    public Scalar $row,
    public Clause $passing,
    list<XmlTableColumn> $columns,
    list<XmlNamespace> $namespaces = [],
    public Name|null $alias = null,
    list<Name> $aliases = [],
    public bool $lateral = false,
)

Parameters

$rowScalarThe XPath expression that yields the rows, a primary expression
$passingClauseThe PASSING clause with the document
$columnslist<XmlTableColumn>The columns in written order; at least one
$namespaceslist<XmlNamespace>The namespaces of XMLNAMESPACES
$aliasName|nullThe correlation name
$aliaseslist<Name>The column names written after the correlation name
$lateralboolWhether LATERAL is written
Calls 7
public function deriveRelation(Derivation $derivation, Environment $environment): RelationFact

Derives the expressions and the columns of the occurrence.

Parameters

$derivationDerivation
$environmentEnvironment
Calls 2
public function render(Output $out): void

Writes LATERAL, XMLTABLE with its namespaces, row expression, PASSING clause and columns, and the alias.

Parameters

$outOutput
Calls 4

Test cases 1§

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

Dedicated tests 1

Relations§

Instantiated in 1
Type checks 4
Type declarations 2