More new SQL/JSON item methods

From: Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: More new SQL/JSON item methods
Date: 2023-08-29 07:05:07
Message-ID: CAM2+6=XjTyqrrqHAOj80r0wVQxJSxc0iyib9bPC55uFO9VKatg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Attached various patches to implement a few more jsonpath item methods.

For context, PostgreSQL already has some item methods, such as .double()
and
.datetime(). The above new methods are just added alongside these.

Here are the brief descriptions for the same.

---

v1-0001-Implement-jsonpath-.bigint-.integer-and-.number-m.patch

This commit implements jsonpath .bigint(), .integer(), and .number()
methods. The JSON string or a numeric value is converted to the
bigint, int4, and numeric type representation.

---

v1-0002-Implement-.date-.time-.time_tz-.timestamp-and-.ti.patch

This commit implements jsonpath .date(), .time(), .time_tz(),
.timestamp(), .timestamp_tz() methods. The JSON string representing
a valid date/time is converted to the specific date or time type
representation.

The changes use the infrastructure of the .datetime() method and
perform the datatype conversion as appropriate. All these methods
accept no argument and use ISO datetime formats.

---

v1-0003-Implement-jsonpath-.boolean-and-.string-methods.patch

This commit implements jsonpath .boolean() and .string() methods.

.boolean() method converts the given JSON string, numeric, or boolean
value to the boolean type representation. In the numeric case, only
integers are allowed, whereas we use the parse_bool() backend function
to convert a string to a bool.

.string() method uses the datatype's out function to convert numeric
and various date/time types to the string representation.

---

v1-0004-Implement-jasonpath-.decimal-precision-scale-meth.patch

This commit implements jsonpath .decimal() method with optional
precision and scale. If precision and scale are provided, then
it is converted to the equivalent numerictypmod and applied to the
numeric number.

---

Suggestions/feedback/comments, please...

Thanks

--
Jeevan Chalke

*Senior Staff SDE, Database Architect, and ManagerProduct Development*

edbpostgres.com

Attachment Content-Type Size
v1-0003-Implement-jsonpath-.boolean-and-.string-methods.patch application/x-patch 22.3 KB
v1-0001-Implement-jsonpath-.bigint-.integer-and-.number-m.patch application/x-patch 32.6 KB
v1-0004-Implement-jasonpath-.decimal-precision-scale-meth.patch application/x-patch 28.6 KB
v1-0002-Implement-.date-.time-.time_tz-.timestamp-and-.ti.patch application/x-patch 68.8 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2023-08-29 07:25:40 Re: logical_replication_mode
Previous Message Heikki Linnakangas 2023-08-29 06:58:48 Re: Use FD_CLOEXEC on ListenSockets (was Re: Refactoring backend fork+exec code)