From: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
---|---|
To: | Thom Brown <thom(at)linux(dot)com> |
Cc: | Dmitry Dolgov <9erthalion6(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: GSoC 2015: Extra Jsonb functionality |
Date: | 2015-03-19 17:08:06 |
Message-ID: | 20150319170806.GK3636@alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Thom Brown wrote:
> On 19 March 2015 at 14:35, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> wrote:
> > Thom Brown wrote:
> >> On 19 March 2015 at 14:12, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> wrote:
> >> > Dmitry Dolgov wrote:
> >> >
> >> >> * jsonb_slice - extract a subset of an jsonb
> >> >> Example of usage:
> Okay, so it pulls it all parents? So I guess you'd get this too:
>
> SELECT jsonb_slice('{"a": 1, "b": {"c": 2}, "d": {"f": 3}, "f":
> 4}'::jsonb, ARRAY['b', 'f', 'x']);
>
> jsonb_slice
> ------------------------------------------------
> {"a": 1, "b": {"c": 2}, "d": {"f": 3}, "f": 4}
Yeah, except "a" wouldn't be output, of course. (The example gets more
interesting if "d" contains more members than just "f". Those would not
get output.)
> >> Although I'm still a bit confused about "f" being produced.
> >
> > I guess you could say that the second argument is an array of element
> > paths, not key names. So to get the result I suggest, you would have to
> > use ARRAY['{b}', '{d,f}', '{x}']. (Hm, this is a non-rectangular
> > array actually... I guess I'd go for ARRAY['b', 'd//f', 'x'] instead, or
> > whatever the convention is to specify a json path).
>
> I think that's where jsquery would come in handy.
If that's what we think, then perhaps we shouldn't accept jsonb_slice at
all because of ambiguous mode of operation.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2015-03-19 17:08:40 | Re: flags argument for dsm_create |
Previous Message | Thom Brown | 2015-03-19 17:01:19 | Re: GSoC 2015: Extra Jsonb functionality |