PG17 has added basic JSON_TABLE() functionality
JSON_TABLE() allows JSON data to be converted into a relational view
and thus used, for example, in a FROM clause, like other tabular
data.
We treat JSON_TABLE the same as correlated functions (e.g., recurring tuples).
In the end, for multi-shard JSON_TABLE commands, we apply the same
restrictions as reference tables (e.g., cannot perform a lateral outer join
when a distributed subquery references a (reference table)/JSON_TABLE etc.)
Relevant PG commit:
https://github.com/postgres/postgres/commit/de3600452
Onder had previously added json table support for PG15BETA1,
but we reverted that commit because json table was reverted in PG15.
ce7f1a530f
Therefore, I referred to that commit for this commit as well,
with a few changes due to some differences between PG15/PG17:
1) In PG15Beta1, we had also PLAN clauses for JSON_TABLE, and Onder's commit
includes tests for those as well. However, PLAN nodes are not added in PG17.
Therefore I didn't include the json_table_select_only test, which had mostly
queries involving PLAN.
2) In PG15 timeline (Citus 11.1), we didn't support outer joins where the
outer rel is a recurring one and the inner one is a non-recurring one.
However, Onur added support for that one in Citus 11.2, therefore I updated
the tests from Onder's commit accordingly.
3) PG17 json table has nested paths and columns, therefore I added a test
with a distributed table, which is exactly the same as the one in
sqljson_jsontable in PG17. https://github.com/postgres/postgres/commit/bb766cde6