From: Andrew Dunstan <andrew@dunslane.net>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Implement various jsonpath methods
Date: Thu, 25 Jan 2024 15:24:28 +0000
Message-ID: <E1rT1ae-0033d6-Hq@gemulon.postgresql.org> (raw)
Implement various jsonpath methods
This commit implements ithe jsonpath .bigint(), .boolean(),
.date(), .decimal([precision [, scale]]), .integer(), .number(),
.string(), .time(), .time_tz(), .timestamp(), and .timestamp_tz()
methods.
.bigint() converts the given JSON string or a numeric value to
the bigint type representation.
.boolean() converts the given JSON string, numeric, or boolean
value to the boolean type representation. In the numeric case, only
integers are allowed. We use the parse_bool() backend function
to convert a string to a bool.
.decimal([precision [, scale]]) converts the given JSON string
or a numeric value to the numeric type representation. If precision
and scale are provided for .decimal(), then it is converted to the
equivalent numeric typmod and applied to the numeric number.
.integer() and .number() convert the given JSON string or a
numeric value to the int4 and numeric type representation.
.string() uses the datatype's output function to convert numeric
and various date/time types to the string representation.
The JSON string representing a valid date/time is converted to the
specific date or time type representation using jsonpath .date(),
.time(), .time_tz(), .timestamp(), .timestamp_tz() methods. The
changes use the infrastructure of the .datetime() method and perform
the datatype conversion as appropriate. Unlike the .datetime()
method, none of these methods accept a format template and use ISO
DateTime format instead. However, except for .date(), the
date/time related methods take an optional precision to adjust the
fractional seconds.
Jeevan Chalke, reviewed by Peter Eisentraut and Andrew Dunstan.
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/66ea94e8e606529bb334515f388c62314956739e
Modified Files
--------------
doc/src/sgml/func.sgml | 218 +++
src/backend/catalog/sql_features.txt | 28 +-
src/backend/utils/adt/jsonpath.c | 138 +-
src/backend/utils/adt/jsonpath_exec.c | 718 +++++++++-
src/backend/utils/adt/jsonpath_gram.y | 78 +-
src/backend/utils/adt/jsonpath_scan.l | 11 +
src/include/utils/jsonpath.h | 11 +
src/test/regress/expected/jsonb_jsonpath.out | 1848 +++++++++++++++++++++++++-
src/test/regress/expected/jsonpath.out | 78 ++
src/test/regress/sql/jsonb_jsonpath.sql | 492 +++++++
src/test/regress/sql/jsonpath.sql | 13 +
11 files changed, 3586 insertions(+), 47 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: andrew@dunslane.net, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Implement various jsonpath methods
In-Reply-To: <E1rT1ae-0033d6-Hq@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox