Re: general purpose array_sort
Junwang Zhao <zhjwpku@gmail.com>
From: Junwang Zhao <zhjwpku@gmail.com>
To: Aleksander Alekseev <aleksander@timescale.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>,
Tom Lane <tgl@sss.pgh.pa.us>, "David G. Johnston" <david.g.johnston@gmail.com>,
jian he <jian.universality@gmail.com>, Amit Langote <amitlangote09@gmail.com>,
"andreas@proxel.se" <andreas@proxel.se>, Robert Haas <robertmhaas@gmail.com>
Date: 2024-10-26T04:20:30Z
Lists: pgsql-hackers
Attachments
- v8-0002-support-sort-order-and-nullsfirst-flag.patch (application/octet-stream) patch v8-0002
- v8-0001-general-purpose-array_sort.patch (application/octet-stream) patch v8-0001
On Fri, Oct 25, 2024 at 8:02 PM Junwang Zhao <zhjwpku@gmail.com> wrote: > > On Fri, Oct 25, 2024 at 1:19 AM Aleksander Alekseev > <aleksander@timescale.com> wrote: > > > > Hi, > > > > > I can accept this outcome though an optional three-valued boolean sort order (ascending and descending only) I'd argue is worth keeping. null value placement too I guess, three-valued boolean (nulls_first). > > > > Perhaps these optional arguments deserve separate discussions. I > > suggest merging something everyone agrees on first. This will simplify > > the review process and allow us to deliver value to the users quickly. > > Arguments like `reverse => true` and `nulls_first => true` can always > > be implemented and added as separate patches. > > As this patch uses the tuplesort infrastructure, we need to supply the > sortOperator, sortCollation and nullsFirstFlag, I tend to agree with > David. I admit that the parsing part is not good, so I will remove it > by using two boolean parameters Jian suggested earlier. > > Will send out another version by tomorrow. Based on the previous discussion, I split it into two patches in V8. 0001 is the general sort part without `is_ascending` or `nulls_first`, the sort order is determined by the "<" operator of the element type. It also cached the type entry of both eletyp and the corresponding array type. 0002 adds the `is_ascending` and `nulls_first` part, it now uses two boolean parameters instead of parsing one text parameter. > > > > > -- > > Best regards, > > Aleksander Alekseev > > > > -- > Regards > Junwang Zhao -- Regards Junwang Zhao
Commits
-
Introduce a SQL-callable function array_sort(anyarray).
- 6c12ae09f5a5 18.0 landed
-
Fix ARRAY_SUBLINK and ARRAY[] for int2vector and oidvector input.
- 4618045bee4a 18.0 cited
-
Re-implement the ereport() macro using __VA_ARGS__.
- e3a87b4991cc 13.0 cited