Re: [PATCH] WIP: replace method for jsonpath

From: Florents Tselai <florents(dot)tselai(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] WIP: replace method for jsonpath
Date: 2024-09-16 22:39:08
Message-ID: 1C4BD5E8-14E8-4A6C-ABD6-D324987B65E3@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Here’s an updated version of this patch.
The previous version failed several CI steps; this passes them all.

Unless someone disagrees,
I’ll proceed with the documentation and add this for the next CF.

As a future note:
It’s worth noting that both this newly added jspItem and other ones like (jpiDecimal, jpiString)
use jspGetRightArg and jspGetLeftArg.
left and right can be confusing if more complex methods are added in the future.
i.e. jsonpath methods with nargs>=3 .
I was wondering if we’d like something like JSP_GETARG(n)

GitHub PR in case you prefer it’s UI https://github.com/Florents-Tselai/postgres/pull/3



> On 15 Sep 2024, at 4:15 AM, Florents Tselai <florents(dot)tselai(at)gmail(dot)com> wrote:
>
> Hi,
>
> When working with jsonb/jsonpath, I’ve always wanted more fluent string operations for data cleaning.
> Ideally, chaining text processing methods together.
>
> Here’s a draft patch that adds a string replace method.
>
> It works like this
> select jsonb_path_query('"hello world"', '$.replace("hello","bye")');
> jsonb_path_query
> ------------------
> "bye world"
> (1 row)
> And looks like plays nicely with existing facilities
>
> select jsonb_path_query('"hello world"', '$.replace("hello","bye") starts with "bye"');
> jsonb_path_query
> ------------------
> true
> (1 row)
> I’d like some initial feedback on whether this is of interested before I proceed with the following:
> - I’ve tried respecting the surrounding code, but a more experienced eye can spot some inconsistencies. I’ll revisit those
> - Add more test cases (I’ve added the obvious ones, but ideas on more cases are welcome).
> - pg upgrades currently fail on CI (see <https://github.com/Florents-Tselai/postgres/pull/3/checks?check_run_id=30154989488>)
> - better error handling/reporting: I’ve kept the wording of error messages, but we’ll need something akin to ERRCODE_INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION.
> - documentation.
>
> <v1-0001-jsonpath-replace-method.patch>

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Tomas Vondra 2024-09-16 22:05:47 Re: Adding skip scan (including MDAM style range skip scan) to nbtree