classJsonTable
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.
$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> $passingpublic non-empty-list<JsonTableColumn> $columnspublic list<Name> $aliasespublic Clause $contextpublic Scalar $pathpublic Name|null $pathName = nullpublic Clause|null $onError = nullpublic Name|null $alias = nullpublic bool $lateral = falseMethods§
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
$context | Clause | The JSON value the rows are read from, with its FORMAT clause |
$path | Scalar | The row path, which PostgreSQL requires to be a string constant |
$columns | list<JsonTableColumn> | The columns in written order; at least one |
$pathName | Name|null | The name of the row path |
$passing | list<Clause> | The PASSING arguments |
$onError | Clause|null | The ON ERROR behavior |
$alias | Name|null | The correlation name |
$aliases | list<Name> | The column names written after the correlation name |
$lateral | bool | Whether LATERAL is written |
Calls 5
- static-call Check::listOf() line 75
- class-const JsonTableColumn::class() line 75
- class-const Clause::class() line 76
- class-const Name::class() line 77
- static-call Check::input() line 78
public function deriveRelation(Derivation $derivation, Environment $environment): RelationFactDerives the expressions and the columns of the occurrence.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 2
- method-call TableFunctionShapes::json() line 86
- new TableFunctionShapes line 86
public function render(Output $out): voidWrites LATERAL, JSON_TABLE with its arguments and columns, and the alias.
Parameters
$out | Output |
Calls 4
- method-call Output::keyword() line 95
- class-const NameUse::Column() line 99
- method-call AliasSpelling::write() line 105
- new AliasSpelling line 105
Test cases 2§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
JsonTableTestcalls
Other tests reaching this symbol 1
Relations§
Instantiated in 1
Type checks 4
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Query\Locking::refused() packages/sql-semantics-postgres/src/Rules/Query/Locking.php:141
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Resolution\FromScope::open() packages/sql-semantics-postgres/src/Rules/Resolution/FromScope.php:61
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Resolution\FromScope::visible() packages/sql-semantics-postgres/src/Rules/Resolution/FromScope.php:75
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Resolution\FromScope::visible() packages/sql-semantics-postgres/src/Rules/Resolution/FromScope.php:80
Type declarations 2
- type SqlSemantics\Platform\PostgreSql\Lowering\Query\TableFunctionRule packages/sql-semantics-postgres/src/Lowering/Query/TableFunctionRule.php:163
- type SqlSemantics\Platform\PostgreSql\Rules\Resolution\TableFunctionShapes packages/sql-semantics-postgres/src/Rules/Resolution/TableFunctionShapes.php:119