Re: Better way to sort a JSONB array?

From: Michael Moore <michaeljmoore(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: postgres list <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Better way to sort a JSONB array?
Date: 2017-08-07 22:10:26
Message-ID: CACpWLjNL9p0rc8ij3Ry7G0+xU8ftUEbro3SWGNz4S-bO_=W1dg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Thanks David, very nice explanation. Yes, functional vs object, got it. I
feel like I can move forward without the feeling that I missed something
obvious.
Regards,
Mike

On Mon, Aug 7, 2017 at 3:04 PM, David G. Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com> wrote:

> On Mon, Aug 7, 2017 at 2:53 PM, Michael Moore <michaeljmoore(at)gmail(dot)com>
> wrote:
>
>> Hi David,
>> Maybe there isn't a less verbose way. It just seems like a bit much that
>> I have to take the jsonb array, convert it into a relation so that SELECT
>> can operate on it, only so that I can sort it, and then convert it back
>> into a jsonb array object. I was hoping for something like
>> json_table2.aggSort("portal_name"). I'm not actually using json_table2
>> as a name, that was just for my minimalist example. As mentioned, my real
>> project consists of refactoring a pgsql function which uses TEMP tables to
>> NOT use temp tables, but instead, JSONB objects.
>>
>>
> ​PostgreSQL is closer to "pure function​al" than "object oriented" if that
> helps explain things. We do a thorough job of documenting the functions we
> do have and a quick skim of the json related functions does not reveal any
> with a signature like: jsonb_sort(array_of_objects_json_array_value
> jsonb, top_level_object_key_name__or_path text). You might want to post
> that as a feature request on -general and see what others more familiar
> with the json implementation think about the idea - we have jsonb_set and
> jsonb_insert so the request isn't completely novel - but as it stands
> today the whole "dis-assemble->act->re-assemble" flow is the one that we
> are stuck with.
>
> David J.
>
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Masaru Sugawara 2017-08-10 10:12:50 Re: Amazon.co.jpからセキュリティコードをお送りします
Previous Message David G. Johnston 2017-08-07 22:04:49 Re: Better way to sort a JSONB array?