Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1282723

Browse files
author
Nikita Glukhov
committed
Add documentation for JSON_TABLE PLAN clause
1 parentf77454f commit1282723

File tree

1 file changed

+82
-15
lines changed

1 file changed

+82
-15
lines changed

‎doc/src/sgml/func.sgml

Lines changed: 82 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18593,9 +18593,10 @@ FROM
1859318593

1859418594
<synopsis>
1859518595
JSON_TABLE (
18596-
<replaceable>context_item</replaceable>, <replaceable>path_expression</replaceable> <optional> PASSING { <replaceable>value</replaceable> AS <replaceable>varname</replaceable> } <optional>, ...</optional> </optional>
18596+
<replaceable>context_item</replaceable>, <replaceable>path_expression</replaceable> <optional>AS <replaceable>json_path_name</replaceable> </optional> <optional>PASSING { <replaceable>value</replaceable> AS <replaceable>varname</replaceable> } <optional>, ...</optional> </optional>
1859718597
COLUMNS ( <replaceable class="parameter">json_table_column</replaceable> <optional>, ...</optional> )
1859818598
<optional>
18599+
PLAN ( <replaceable class="parameter">json_table_plan</replaceable> ) |
1859918600
PLAN DEFAULT ( { INNER | OUTER } <optional> , { CROSS | UNION } </optional>
1860018601
| { CROSS | UNION } <optional> , { INNER | OUTER } </optional> )
1860118602
</optional>
@@ -18619,6 +18620,16 @@ where <replaceable class="parameter">json_table_column</replaceable> is:
1861918620
| NESTED PATH <replaceable>json_path_specification</replaceable> <optional> AS <replaceable>path_name</replaceable> </optional>
1862018621
COLUMNS ( <replaceable>json_table_column</replaceable> <optional>, ...</optional> )
1862118622
| <replaceable>name</replaceable> FOR ORDINALITY
18623+
<phrase>
18624+
<replaceable>json_table_plan</replaceable> is:
18625+
</phrase>
18626+
<replaceable>json_path_name</replaceable> <optional> { OUTER | INNER } <replaceable>json_table_plan_primary</replaceable> </optional>
18627+
| <replaceable>json_table_plan_primary</replaceable> { UNION <replaceable>json_table_plan_primary</replaceable> } <optional>...</optional>
18628+
| <replaceable>json_table_plan_primary</replaceable> { CROSS <replaceable>json_table_plan_primary</replaceable> } <optional>...</optional>
18629+
<phrase>
18630+
<replaceable>json_table_plan_primary</replaceable> is:
18631+
</phrase>
18632+
<replaceable>json_path_name</replaceable> | ( <replaceable>json_table_plan</replaceable> )
1862218633

1862318634
</synopsis>
1862418635

@@ -18661,7 +18672,7 @@ where <replaceable class="parameter">json_table_column</replaceable> is:
1866118672
joined to the row that generated them, so you do not have to explicitly join
1866218673
the constructed view with the original table holding <acronym>JSON</acronym>
1866318674
data. Optionally, you can specify how to join the columns returned
18664-
by <literal>NESTED PATH</literal> using the <literal>PLAN DEFAULT</literal> clause.
18675+
by <literal>NESTED PATH</literal> using the <literal>PLAN</literal> clause.
1866518676
</para>
1866618677

1866718678
<para>
@@ -18846,7 +18857,7 @@ where <replaceable class="parameter">json_table_column</replaceable> is:
1884618857
</para>
1884718858

1884818859
<para>
18849-
You can use the <literal>PLAN DEFAULT</literal> clause to define how
18860+
You can use the <literal>PLAN</literal> clause to define how
1885018861
to join the columns returned by <replaceable>NESTED PATH</replaceable> clauses.
1885118862
</para>
1885218863
</listitem>
@@ -18873,18 +18884,31 @@ where <replaceable class="parameter">json_table_column</replaceable> is:
1887318884

1887418885
<varlistentry>
1887518886
<term>
18876-
<literal>PLAN DEFAULT (<replaceable>option</replaceable> <optional>, ... </optional> )</literal>
18887+
<literal>AS<replaceable>json_path_name</replaceable></literal>
1887718888
</term>
1887818889
<listitem>
18879-
<para>
18880-
Defines how to join the data returned by <replaceable>NESTED PATH</replaceable>
18881-
clauses to the constructed view. The <literal>INNER</literal> and
18882-
<literal>OUTER</literal> options define the joining plan for parent/child
18883-
columns, while <literal>UNION</literal> and <literal>CROSS</literal>
18884-
affect the sibling columns. You can override the default plans for all
18885-
columns at once.
18886-
</para>
1888718890

18891+
<para>
18892+
The optional <replaceable>json_path_name</replaceable> serves as an
18893+
identifier of the provided <replaceable>json_path_specification</replaceable>.
18894+
The path name must be unique and cannot coincide with column names.
18895+
When using the <literal>PLAN</literal> clause, you must specify the names
18896+
for all the paths, including the row pattern. Each path name can appear in
18897+
the <literal>PLAN</literal> clause only once.
18898+
</para>
18899+
</listitem>
18900+
</varlistentry>
18901+
18902+
<varlistentry>
18903+
<term>
18904+
<literal>PLAN ( <replaceable class="parameter">json_table_plan</replaceable> )</literal>
18905+
</term>
18906+
<listitem>
18907+
18908+
<para>
18909+
Defines how to join the data returned by <replaceable>NESTED PATH</replaceable>
18910+
clauses to the constructed view.
18911+
</para>
1888818912
<para>
1888918913
To join columns with parent/child relationship, you can use:
1889018914
</para>
@@ -18963,6 +18987,23 @@ where <replaceable class="parameter">json_table_column</replaceable> is:
1896318987

1896418988
</listitem>
1896518989
</varlistentry>
18990+
18991+
<varlistentry>
18992+
<term>
18993+
<literal>PLAN DEFAULT ( <replaceable>option</replaceable> <optional>, ... </optional> )</literal>
18994+
</term>
18995+
<listitem>
18996+
<para>
18997+
Overrides the default joining plans. The <literal>INNER</literal> and
18998+
<literal>OUTER</literal> options define the joining plan for parent/child
18999+
columns, while <literal>UNION</literal> and <literal>CROSS</literal>
19000+
affect the sibling columns. You can override the default plans for all columns at once.
19001+
Even though the path names are not incuded into the <literal>PLAN DEFAULT</literal>
19002+
clause, they must be provided for all the paths to conform to
19003+
the SQL/JSON standard.
19004+
</para>
19005+
</listitem>
19006+
</varlistentry>
1896619007
</variablelist>
1896719008
</sect5>
1896819009

@@ -18994,9 +19035,35 @@ SELECT jt.* FROM
1899419035
</screen>
1899519036
</para>
1899619037

18997-
</sect5>
18998-
</sect4>
18999-
19038+
<para>
19039+
Find a director that has done films in two different genres:
19040+
<screen>
19041+
SELECT
19042+
director1 AS director, title1, kind1, title2, kind2
19043+
FROM
19044+
my_films,
19045+
JSON_TABLE ( js, '$.favorites' AS favs COLUMNS (
19046+
NESTED PATH '$[*]' AS films1 COLUMNS (
19047+
kind1 text PATH '$.kind',
19048+
NESTED PATH '$.films[*]' AS film1 COLUMNS (
19049+
title1 text PATH '$.title',
19050+
director1 text PATH '$.director')
19051+
),
19052+
NESTED PATH '$[*]' AS films2 COLUMNS (
19053+
kind2 text PATH '$.kind',
19054+
NESTED PATH '$.films[*]' AS film2 COLUMNS (
19055+
title2 text PATH '$.title',
19056+
director2 text PATH '$.director'
19057+
)
19058+
)
19059+
)
19060+
PLAN (favs OUTER ((films1 INNER film1) CROSS (films2 INNER film2)))
19061+
) AS jt
19062+
WHERE kind1 > kind2 AND director1 = director2;
19063+
</screen>
19064+
</para>
19065+
</sect5>
19066+
</sect4>
1900019067
</sect3>
1900119068

1900219069
<sect3 id="functions-sqljson-serializing">

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp