pgsql: JSON_TABLE PLAN clause

From: Alexander Korotkov <akorotkov(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: JSON_TABLE PLAN clause
Date: 2026-07-09 11:56:08
Message-ID: E1whnMN-000I6O-2b@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

JSON_TABLE PLAN clause

This patch adds the PLAN clauses for JSON_TABLE, which allow the user
to specify how data from nested paths are joined, allowing
considerable freedom in shaping the tabular output of JSON_TABLE.
PLAN DEFAULT allows the user to specify the global strategies when
dealing with sibling or child nested paths. This is often sufficient
to achieve the necessary goal, and is considerably simpler than the
full PLAN clause, which allows the user to specify the strategy to be
used for each named nested path.

Path names may be attached to the row pattern and to each NESTED path
using AS. Unlike the SQL/JSON standard, which requires a name for every
NESTED path when a PLAN clause is present, PostgreSQL does not require
them and generates a name for any path left unnamed; a specific PLAN()
can only reference paths by name, so unnamed paths it must mention are
reported as not covered by the plan.

Author: Nikita Malakhov <n(dot)malakhov(at)postgrespro(dot)ru>
Co-authored-by: Nikita Glukhov <n(dot)gluhov(at)postgrespro(dot)ru>
Co-authored-by: Teodor Sigaev <teodor(at)sigaev(dot)ru>
Co-authored-by: Oleg Bartunov <obartunov(at)gmail(dot)com>
Co-authored-by: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
Co-authored-by: Andrew Dunstan <andrew(at)dunslane(dot)net>
Co-authored-by: Amit Langote <amitlangote09(at)gmail(dot)com>
Co-authored-by: Anton Melnikov <a(dot)melnikov(at)postgrespro(dot)ru>
Reviewed-by: Andres Freund <andres(at)anarazel(dot)de>
Reviewed-by: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Reviewed-by: Andrew Alsup <bluesbreaker(at)gmail(dot)com>
Reviewed-by: Erik Rijkers <er(at)xs4all(dot)nl>
Reviewed-by: Zhihong Yu <zyu(at)yugabyte(dot)com>
Reviewed-by: Himanshu Upadhyaya <upadhyaya(dot)himanshu(at)gmail(dot)com>
Reviewed-by: Daniel Gustafsson <daniel(at)yesql(dot)se>
Reviewed-by: Justin Pryzby <pryzby(at)telsasoft(dot)com>
Reviewed-by: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Reviewed-by: jian he <jian(dot)universality(at)gmail(dot)com>
Reviewed-by: Vladlen Popolitov <v(dot)popolitov(at)postgrespro(dot)ru>
Discussion: https://postgr.es/m/cd0bb935-0158-78a7-08b5-904886deac4b@postgrespro.ru
Discussion: https://postgr.es/m/20220616233130.rparivafipt6doj3@alap3.anarazel.de
Discussion: https://postgr.es/m/abd9b83b-aa66-f230-3d6d-734817f0995d%40postgresql.org
Discussion: https://postgr.es/m/CA+HiwqE4XTdfb1nW=Ojoy_tQSRhYt-q_kb6i5d4xcKyrLC1Nbg@mail.gmail.com
Discussion: https://postgr.es/m/CAN-LCVP7HXmGu-WcinsHvdKqMGEdv=1Y67H4U58F6Y=Q0M5GyQ@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/86ab7f4c721d61282c058acc0b4aa0b3adf04410

Modified Files
--------------
doc/src/sgml/func/func-json.sgml | 176 ++++++-
src/backend/catalog/sql_features.txt | 4 +-
src/backend/nodes/makefuncs.c | 54 ++
src/backend/parser/gram.y | 101 +++-
src/backend/parser/parse_jsontable.c | 382 +++++++++++---
src/backend/utils/adt/jsonpath_exec.c | 171 +++++--
src/backend/utils/adt/ruleutils.c | 99 ++++
src/include/nodes/makefuncs.h | 5 +
src/include/nodes/parsenodes.h | 43 ++
src/include/nodes/primnodes.h | 2 +
src/test/regress/expected/sqljson_jsontable.out | 655 +++++++++++++++++++++++-
src/test/regress/sql/sqljson_jsontable.sql | 434 ++++++++++++++++
src/tools/pgindent/typedefs.list | 3 +
13 files changed, 2017 insertions(+), 112 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2026-07-09 12:17:46 pgsql: Fix advertising autovacuum launcher's ProcNumber
Previous Message Thom Brown 2026-07-09 11:09:23 Re: pgsql: Refactor how some aux processes advertise their ProcNumber