From: | Oleg Bartunov <obartunov(at)postgrespro(dot)ru> |
---|---|
To: | Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru> |
Cc: | Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, Nikita Glukhov <n(dot)gluhov(at)postgrespro(dot)ru>, Michael Paquier <michael(at)paquier(dot)xyz>, Stas Kelvich <s(dot)kelvich(at)postgrespro(dot)ru>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>, David Steele <david(at)pgmasters(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
Subject: | Re: jsonpath |
Date: | 2019-01-21 15:04:48 |
Message-ID: | CAF4Au4x8wELTcwu0XS9nSZwNfJEFitNjU=_M=1WzHtdBPkwVpw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, Jan 21, 2019 at 1:40 AM Alexander Korotkov
<a(dot)korotkov(at)postgrespro(dot)ru> wrote:
>
> On Sun, Jan 20, 2019 at 6:30 AM Alexander Korotkov
> <a(dot)korotkov(at)postgrespro(dot)ru> wrote:
> > I'll continue revising this patchset. Nikita, could you please write
> > tests for 3-argument versions of functions? Also, please answer the
> > question regarding "id" property.
>
> I've some more notes regarding function set provided in jsonpath patch:
> 1) Function names don't follow the convention we have. All our
> functions dealing with jsonb have "jsonb_" prefix. Exclusions have
> "jsonb" in other part of name, for example, "to_jsonb(anyelement)".
> We could name functions at SQL level in the same way they are named in
> C. So, they would be jsonb_jsonpath_exists() etc. But it's probably
> too long. What about jsonb_path_exists() etc?
jsonpath_exists is similar to xpath_exists.
Actually, we could use jsonb_exists(jsonb, jsonpath, json), but then
we should specify the type of the second argument.
> 2) jsonpath_query_wrapped() name seems counter intuitive for me. What
> about jsonpath_query_array()?
The question is should we try to provide a functional interface for
all options of
JSON_QUERY clause ? The same is for other SQL/JSON clauses.
Currently, patch contains very limited subset of JSON_QUERY
functionality, mostly for jsonpath testing.
> 3) jsonpath_query_wrapped() behavior looks tricky to me. It returns
> NULL for no results. When result item is one, it is returned "as is".
> When there are two or more result items, they are wrapped into array.
> This representation of result seems extremely inconvenient for me. It
> becomes hard to solve even trivial tasks with that: for instance,
> iterate all items found. Without extra assumptions on what is going
> to be returned it's also impossible for caller to distinguish single
> array item found from multiple items found wrapped into array. And
> that seems very bad. I know this behavior is inspired by SQL/JSON
> standard. But since these functions are anyway our extension, we can
> implement them as we like. So, I propose to make this function always
> return array of items regardless on count of those items (even for 1
> or 0 items).
Fair enough, but if we agree, that we provide an exact functionality of
SQL clauses, then better to follow the standard to avoid problems.
> 4) If we change behavior of jsonpath_query_wrapped() as above, we can
> also implement jsonpath_query_one() function, which would return first
> result item or NULL for no items.
> Any thoughts?
I think, that we should postpone this functional interface, which could be
added later.
>
> ------
> Alexander Korotkov
> Postgres Professional: http://www.postgrespro.com
> The Russian Postgres Company
--
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
From | Date | Subject | |
---|---|---|---|
Next Message | Tomas Vondra | 2019-01-21 15:22:11 | Re: COPY FROM WHEN condition |
Previous Message | Tomas Vondra | 2019-01-21 14:56:34 | Re: [PROPOSAL] Shared Ispell dictionaries |