]> git.ipfire.org Git - thirdparty/postgresql.git/commit
JSON_TABLE PLAN clause
authorAlexander Korotkov <akorotkov@postgresql.org>
Thu, 9 Jul 2026 11:37:31 +0000 (14:37 +0300)
committerAlexander Korotkov <akorotkov@postgresql.org>
Thu, 9 Jul 2026 11:37:31 +0000 (14:37 +0300)
commit86ab7f4c721d61282c058acc0b4aa0b3adf04410
tree98e9911b2e002b9bedc188754adc46a350eb0f02
parent2e6578292a9184dcaae6c5abc235a26db9cb2973
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.malakhov@postgrespro.ru>
Co-authored-by: Nikita Glukhov <n.gluhov@postgrespro.ru>
Co-authored-by: Teodor Sigaev <teodor@sigaev.ru>
Co-authored-by: Oleg Bartunov <obartunov@gmail.com>
Co-authored-by: Alexander Korotkov <aekorotkov@gmail.com>
Co-authored-by: Andrew Dunstan <andrew@dunslane.net>
Co-authored-by: Amit Langote <amitlangote09@gmail.com>
Co-authored-by: Anton Melnikov <a.melnikov@postgrespro.ru>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Pavel Stehule <pavel.stehule@gmail.com>
Reviewed-by: Andrew Alsup <bluesbreaker@gmail.com>
Reviewed-by: Erik Rijkers <er@xs4all.nl>
Reviewed-by: Zhihong Yu <zyu@yugabyte.com>
Reviewed-by: Himanshu Upadhyaya <upadhyaya.himanshu@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Justin Pryzby <pryzby@telsasoft.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: jian he <jian.universality@gmail.com>
Reviewed-by: Vladlen Popolitov <v.popolitov@postgrespro.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
13 files changed:
doc/src/sgml/func/func-json.sgml
src/backend/catalog/sql_features.txt
src/backend/nodes/makefuncs.c
src/backend/parser/gram.y
src/backend/parser/parse_jsontable.c
src/backend/utils/adt/jsonpath_exec.c
src/backend/utils/adt/ruleutils.c
src/include/nodes/makefuncs.h
src/include/nodes/parsenodes.h
src/include/nodes/primnodes.h
src/test/regress/expected/sqljson_jsontable.out
src/test/regress/sql/sqljson_jsontable.sql
src/tools/pgindent/typedefs.list