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

JSON_TABLE as a FROM item: rows and columns read from a JSON value (PostgreSQL 17).

Mirrors PostgreSQL's JsonTable. The facts follow PG-JSON-TABLE-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-json.html#FUNCTIONS-SQLJSON-TABLE. Status: Implemented.

Reading the columns of JSON_TABLEdoctest
$query = (new \SqlSemantics\Platform\PostgreSql\Semantics('pg-17.2'))->analyze("SELECT * FROM JSON_TABLE ('[]', '$[*]' AS p COLUMNS (n FOR ORDINALITY, e boolean EXISTS)) AS j");
    [$query->statement->from->pathName->value, $query->field(0)->type->descriptor->name(), $query->field(1)->name->value] // => ['p', 'integer', 'e']

Properties§

public list<Clause> $passing
public non-empty-list<JsonTableColumn> $columns
public list<Name> $aliases
public Clause $context
public Scalar $path
public Name|null $pathName = null
public Clause|null $onError = null
public Name|null $alias = null
public bool $lateral = false

Methods§

public function __construct(
    public Clause $context,
    public Scalar $path,
    list<JsonTableColumn> $columns,
    public Name|null $pathName = null,
    list<Clause> $passing = [],
    public Clause|null $onError = null,
    public Name|null $alias = null,
    list<Name> $aliases = [],
    public bool $lateral = false,
)

Parameters

$contextClauseThe JSON value the rows are read from, with its FORMAT clause
$pathScalarThe row path, which PostgreSQL requires to be a string constant
$columnslist<JsonTableColumn>The columns in written order; at least one
$pathNameName|nullThe name of the row path
$passinglist<Clause>The PASSING arguments
$onErrorClause|nullThe ON ERROR behavior
$aliasName|nullThe correlation name
$aliaseslist<Name>The column names written after the correlation name
$lateralboolWhether LATERAL is written
Calls 5
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, JSON_TABLE with its arguments and columns, and the alias.

Parameters

$outOutput
Calls 4

Test cases 2§

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

Dedicated tests 1
Other tests reaching this symbol 1

Relations§

Instantiated in 1
Type checks 4
Type declarations 2