@@ -18593,9 +18593,10 @@ FROM
18593
18593
18594
18594
18595
18595
JSON_TABLE (
18596
- context_item , path_expression PASSING { value AS varname } , ...
18596
+ context_item , path_expression AS json_path_name PASSING { value AS varname } , ...
18597
18597
COLUMNS ( json_table_column , ... )
18598
18598
18599
+ PLAN ( json_table_plan ) |
18599
18600
PLAN DEFAULT ( { INNER | OUTER } , { CROSS | UNION }
18600
18601
| { CROSS | UNION } , { INNER | OUTER } )
18601
18602
@@ -18619,6 +18620,16 @@ where json_table_column is:
18619
18620
| NESTED PATH json_path_specification AS path_name
18620
18621
COLUMNS ( json_table_column , ... )
18621
18622
| name FOR ORDINALITY
18623
+
18624
+ json_table_plan is:
18625
+
18626
+ json_path_name { OUTER | INNER } json_table_plan_primary
18627
+ | json_table_plan_primary { UNION json_table_plan_primary } ...
18628
+ | json_table_plan_primary { CROSS json_table_plan_primary } ...
18629
+
18630
+ json_table_plan_primary is:
18631
+
18632
+ json_path_name | ( json_table_plan )
18622
18633
18623
18634
18624
18635
@@ -18661,7 +18672,7 @@ where json_table_column is:
18661
18672
joined to the row that generated them, so you do not have to explicitly join
18662
18673
the constructed view with the original table holding
JSON
18663
18674
data. Optionally, you can specify how to join the columns returned
18664
- by NESTED PATH using the PLAN DEFAULT clause.
18675
+ by NESTED PATH using the PLAN clause.
18665
18676
18666
18677
18667
18678
@@ -18846,7 +18857,7 @@ where json_table_column is:
18846
18857
18847
18858
18848
18859
18849
- You can use the PLAN DEFAULT clause to define how
18860
+ You can use the PLAN clause to define how
18850
18861
to join the columns returned by NESTED PATH clauses.
18851
18862
18852
18863
@@ -18873,18 +18884,31 @@ where json_table_column is:
18873
18884
18874
18885
18875
18886
18876
- PLAN DEFAULT ( option , ... )
18887
+ AS json_path_name
18877
18888
18878
18889
18879
-
18880
- Defines how to join the data returned by NESTED PATH
18881
- clauses to the constructed view. The INNER and
18882
- OUTER options define the joining plan for parent/child
18883
- columns, while UNION and CROSS
18884
- affect the sibling columns. You can override the default plans for all
18885
- columns at once.
18886
-
18887
18890
18891
+
18892
+ The optional json_path_name serves as an
18893
+ identifier of the provided json_path_specification .
18894
+ The path name must be unique and cannot coincide with column names.
18895
+ When using the PLAN clause, you must specify the names
18896
+ for all the paths, including the row pattern. Each path name can appear in
18897
+ the PLAN clause only once.
18898
+
18899
+
18900
+
18901
+
18902
+
18903
+
18904
+ PLAN ( json_table_plan )
18905
+
18906
+
18907
+
18908
+
18909
+ Defines how to join the data returned by NESTED PATH
18910
+ clauses to the constructed view.
18911
+
18888
18912
18889
18913
To join columns with parent/child relationship, you can use:
18890
18914
@@ -18963,6 +18987,23 @@ where json_table_column is:
18963
18987
18964
18988
18965
18989
18990
+
18991
+
18992
+
18993
+ PLAN DEFAULT ( option , ... )
18994
+
18995
+
18996
+
18997
+ Overrides the default joining plans. The INNER and
18998
+ OUTER options define the joining plan for parent/child
18999
+ columns, while UNION and CROSS
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 PLAN DEFAULT
19002
+ clause, they must be provided for all the paths to conform to
19003
+ the SQL/JSON standard.
19004
+
19005
+
19006
+
18966
19007
18967
19008
18968
19009
@@ -18994,9 +19035,35 @@ SELECT jt.* FROM
18994
19035
18995
19036
18996
19037
18997
-
18998
-
18999
-
19038
+
19039
+ Find a director that has done films in two different genres:
19040
+
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
+
19064
+
19065
+
19066
+
19000
19067
19001
19068
19002
19069
0 commit comments