Re: jsonb concatenate operator's semantics seem questionable

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: Peter Geoghegan <pg(at)heroku(dot)com>, Ryan Pedela <rpedela(at)datalanche(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Dmitry Dolgov <9erthalion6(at)gmail(dot)com>, Petr Jelinek <petr(at)2ndquadrant(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Ilya Ashchepkov <koctep(at)gmail(dot)com>
Subject: Re: jsonb concatenate operator's semantics seem questionable
Date: 2015-05-18 20:54:33
Message-ID: CAKFQuwYYsBy4c6-XVs=T+RzHx08=bW1=Rx2ycmOiMdk63p9i-A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, May 18, 2015 at 12:12 PM, Josh Berkus <josh(at)agliodbs(dot)com> wrote:

> On 05/18/2015 11:58 AM, Peter Geoghegan wrote:
> > As you say, hstore isn't nested, and so this simply doesn't come up
> > there. We have failed to adopt "||" to jsonb in a way that makes
> > sense. We should have adopted it to jsonb in exactly the same way as
> > the "@>" operator was.
>
> The only question worth discussing is whether we change the operator to
> "+" (or, for that matter, something else). I've seen your vote on this,
> so, does anyone else have an opinion on "+" vs. "||"? Preferably with a
> justification with some kind of grounding?
>

How about a pair of operators?

​jsonb |> jsonb​ "push these keys into that jsonb, replacing existing
values for any keys already present"
​jsonb <| jsonb​ "pull those keys into this jsonb, [...]"

I do suspect, however, that any kind of deep concatenation/replacement
algorithm is going to require end-user input and thus will want to be done
strictly through functions as opposed to operators.

Given the complexity of json I'm not convinced that either + or || should
end up being implemented. Those are operators best left to simple types
where the meaning of "add" and "concatenate" are well defined. Even if we
do end up with the deep "concatenation" algorithm, and decide to turn it
into an operator, at this moment I would not choose || to be that operator.

This entire thread is the justification for the last
paragraph...unfortunately the rest is just my opinion.

David J.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2015-05-18 21:09:45 Re: Minor ON CONFLICT related fixes
Previous Message Peter Geoghegan 2015-05-18 20:53:39 Re: Minor ON CONFLICT related fixes