classJsonTable
final class JsonTable
implements Relation
uses Snapshot
Public API: explicitly declared with
@visibility public.The table function JSON_TABLE(document, path COLUMNS (...)) [AS] alias.
Rule: MYSQL-JSON-TABLE-001. The document expression sees the enclosing queries and the tables to its left in the same FROM clause (MYSQL-FROM-SCOPE-001). The columns are the slots the column definitions contribute, nested paths flattened in order. A table function without alias is reported. Source: https://dev.mysql.com/doc/refman/8.4/en/json-table-functions.html. Status: Implemented.
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze("SELECT a FROM JSON_TABLE('[1]', '$[*]' COLUMNS (a INT PATH '$')) AS j");
$query->statement->from->alias?->value // => 'j'Properties§
public non-empty-list<JsonTableColumn> $columnspublic Scalar $documentpublic StringLiteral $pathpublic Name|null $alias = nullpublic AliasMark $mark = AliasMark::AsMethods§
public function __construct(
public Scalar $document,
public StringLiteral $path,
list<JsonTableColumn> $columns,
public Name|null $alias = null,
public AliasMark $mark = AliasMark::As,
)Parameters
$document | Scalar | The JSON document |
$path | StringLiteral | The path of the rows |
$columns | list<JsonTableColumn> | The column definitions; at least one |
$alias | Name|null | The correlation name |
$mark | AliasMark | What is written before the alias |
Calls 4
- class-const AliasMark::As() line 56
- static-call Check::input() line 58
- static-call Check::listOf() line 59
- class-const JsonTableColumn::class() line 59
public function deriveRelation(Derivation $derivation, Environment $environment): RelationFactDerives the document, the path and the columns.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 7
- method-call Derivation::report() line 68
- new Misuse line 68
- class-const MisuseRule::TableFunctionWithoutAlias() line 68
- method-call Derivation::scalar() line 70
- function-call
array_pushline 74 - new RelationFact line 77
- new RowShape line 77
public function render(Output $out): voidWrites the table function.
Parameters
$out | Output |
Calls 4
- method-call Output::keyword() line 85
- method-call AliasMark::write() line 88
- method-call Output::name() line 89
- class-const NameUse::Alias() line 89
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
- instanceof SqlSemantics\Platform\MySql\Rules\Dml\ChangeFacts::updatable() packages/sql-semantics-mysql/src/Rules/Dml/ChangeFacts.php:118
- instanceof SqlSemantics\Platform\MySql\Rules\Dml\SourceRelations::visible() packages/sql-semantics-mysql/src/Rules/Dml/SourceRelations.php:62
- instanceof SqlSemantics\Platform\MySql\Rules\Query\From\FromScope::open() packages/sql-semantics-mysql/src/Rules/Query/From/FromScope.php:59
- instanceof SqlSemantics\Platform\MySql\Rules\Query\From\FromScope::open() packages/sql-semantics-mysql/src/Rules/Query/From/FromScope.php:63