Re: More new SQL/JSON item methods

From: Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: Peter Eisentraut <peter(at)eisentraut(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: More new SQL/JSON item methods
Date: 2023-10-19 06:07:58
Message-ID: CAM2+6=WNGQ6GYcR7bkm=O46bwYG39ZKkGTJ9j2tdO25tZHbtvA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Oct 18, 2023 at 4:50 PM jian he <jian(dot)universality(at)gmail(dot)com> wrote:

> On Fri, Oct 6, 2023 at 7:47 PM Peter Eisentraut <peter(at)eisentraut(dot)org>
> wrote:
> >
> > On 29.08.23 09:05, Jeevan Chalke wrote:
> > > 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.
> >
> > A comment that applies to all of these: These add various keywords,
> > switch cases, documentation entries in some order. Are we happy with
> > that? Should we try to reorder all of that for better maintainability
> > or readability?
> >
> > > 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.
> >
> > These should accept an optional precision argument. Did you plan to add
> > that?
>
> compiler warnings issue resolved.
>

Thanks for pitching in, Jian.
I was slightly busy with other stuff and thus could not spend time on this.

I will start looking into it and expect a patch in a couple of days.

> I figured out how to use the precision argument.
> But I don't know how to get the precision argument in the parse stage.
>
> attached is my attempt to implement: select
> jsonb_path_query('"2017-03-10 11:11:01.123"', '$.timestamp(2)');
> not that familiar with src/backend/utils/adt/jsonpath_gram.y. imitate
> decimal method failed. decimal has precision and scale two arguments.
> here only one argument.
>
> looking for hints.
>

You may refer to how .datetime(<format>) is implemented.

Thanks

--
Jeevan Chalke

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

edbpostgres.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Shlok Kyal 2023-10-19 06:21:27 Re: [PoC] pg_upgrade: allow to upgrade publisher node
Previous Message Jeevan Chalke 2023-10-19 06:06:37 Re: More new SQL/JSON item methods