public inbox for [email protected]  
help / color / mirror / Atom feed
Proposal to improve uniq function documentation in intarray extension
5+ messages / 4 participants
[nested] [flat]

* Proposal to improve uniq function documentation in intarray extension
@ 2022-06-01 10:20 PG Doc comments form <[email protected]>
  2022-06-03 15:34 ` Re: Proposal to improve uniq function documentation in intarray extension Tom Lane <[email protected]>
  0 siblings, 1 reply; 5+ messages in thread

From: PG Doc comments form @ 2022-06-01 10:20 UTC (permalink / raw)
  To: [email protected]; +Cc: [email protected]

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/14/intarray.html
Description:

The **uniq** function in the **intarray** extension removes **adjacent**
duplicates from an integer array. The documentation[0] about this behavior
is correct, but the example is a bit misleading, because it sorts the array
before applying uniq. The sort can be overlooked **easily** and leads to the
impression that **uniq** removes all duplicates from the array.

I propse to change the example to somthing like that:

  uniq('{1,2,2,3,1,1}'::integer[]) → {1,2,3,1}

It might be a good idea to refer to the **sort** function in case one wants
to remove all duplicates.

Cheers, Martin Kalcher

[0]
https://www.postgresql.org/docs/current/intarray.html#INTARRAY-FUNC-TABLE


^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Proposal to improve uniq function documentation in intarray extension
  2022-06-01 10:20 Proposal to improve uniq function documentation in intarray extension PG Doc comments form <[email protected]>
@ 2022-06-03 15:34 ` Tom Lane <[email protected]>
  2022-06-03 17:05   ` Re: Proposal to improve uniq function documentation in intarray extension Daniel Gustafsson <[email protected]>
  0 siblings, 1 reply; 5+ messages in thread

From: Tom Lane @ 2022-06-03 15:34 UTC (permalink / raw)
  To: [email protected]; +Cc: [email protected]

PG Doc comments form <[email protected]> writes:
> The **uniq** function in the **intarray** extension removes **adjacent**
> duplicates from an integer array. The documentation[0] about this behavior
> is correct, but the example is a bit misleading, because it sorts the array
> before applying uniq. The sort can be overlooked **easily** and leads to the
> impression that **uniq** removes all duplicates from the array.

> I propse to change the example to somthing like that:

>   uniq('{1,2,2,3,1,1}'::integer[]) → {1,2,3,1}

You have a point, but the example of use with sort() is pretty useful in
its own right, particularly for people for whom "blah blah | sort | uniq"
is not second nature.  Fortunately, there's no longer any reason we have
to limit ourselves to one example.  I propose this:

diff --git a/doc/src/sgml/intarray.sgml b/doc/src/sgml/intarray.sgml
index f930c08eeb..18c6f8c3ba 100644
--- a/doc/src/sgml/intarray.sgml
+++ b/doc/src/sgml/intarray.sgml
@@ -131,6 +131,11 @@
        </para>
        <para>
         Removes adjacent duplicates.
+        Often used with <function>sort</function> to remove all duplicates.
+       </para>
+       <para>
+        <literal>uniq('{1,2,2,3,1,1}'::integer[])</literal>
+        <returnvalue>{1,2,3,1}</returnvalue>
        </para>
        <para>
         <literal>uniq(sort('{1,2,3,2,1}'::integer[]))</literal>


			regards, tom lane





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Proposal to improve uniq function documentation in intarray extension
  2022-06-01 10:20 Proposal to improve uniq function documentation in intarray extension PG Doc comments form <[email protected]>
  2022-06-03 15:34 ` Re: Proposal to improve uniq function documentation in intarray extension Tom Lane <[email protected]>
@ 2022-06-03 17:05   ` Daniel Gustafsson <[email protected]>
  2022-06-03 17:55     ` Re: Proposal to improve uniq function documentation in intarray extension Tom Lane <[email protected]>
  0 siblings, 1 reply; 5+ messages in thread

From: Daniel Gustafsson @ 2022-06-03 17:05 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; +Cc: [email protected]; [email protected]

> On 3 Jun 2022, at 17:34, Tom Lane <[email protected]> wrote:

> .. there's no longer any reason we have
> to limit ourselves to one example.  I propose this:
> 
> diff --git a/doc/src/sgml/intarray.sgml b/doc/src/sgml/intarray.sgml
> index f930c08eeb..18c6f8c3ba 100644
> --- a/doc/src/sgml/intarray.sgml
> +++ b/doc/src/sgml/intarray.sgml
> @@ -131,6 +131,11 @@
>        </para>
>        <para>
>         Removes adjacent duplicates.
> +        Often used with <function>sort</function> to remove all duplicates.
> +       </para>
> +       <para>
> +        <literal>uniq('{1,2,2,3,1,1}'::integer[])</literal>
> +        <returnvalue>{1,2,3,1}</returnvalue>
>        </para>
>        <para>
>         <literal>uniq(sort('{1,2,3,2,1}'::integer[]))</literal>

+1

--
Daniel Gustafsson		https://vmware.com/






^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Proposal to improve uniq function documentation in intarray extension
  2022-06-01 10:20 Proposal to improve uniq function documentation in intarray extension PG Doc comments form <[email protected]>
  2022-06-03 15:34 ` Re: Proposal to improve uniq function documentation in intarray extension Tom Lane <[email protected]>
  2022-06-03 17:05   ` Re: Proposal to improve uniq function documentation in intarray extension Daniel Gustafsson <[email protected]>
@ 2022-06-03 17:55     ` Tom Lane <[email protected]>
  2022-06-07 08:48       ` Re: Proposal to improve uniq function documentation in intarray extension Martin Kalcher <[email protected]>
  0 siblings, 1 reply; 5+ messages in thread

From: Tom Lane @ 2022-06-03 17:55 UTC (permalink / raw)
  To: Daniel Gustafsson <[email protected]>; +Cc: [email protected]; [email protected]

Daniel Gustafsson <[email protected]> writes:
>> On 3 Jun 2022, at 17:34, Tom Lane <[email protected]> wrote:
>> .. there's no longer any reason we have
>> to limit ourselves to one example.  I propose this:

> +1

Done like that, then.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Proposal to improve uniq function documentation in intarray extension
  2022-06-01 10:20 Proposal to improve uniq function documentation in intarray extension PG Doc comments form <[email protected]>
  2022-06-03 15:34 ` Re: Proposal to improve uniq function documentation in intarray extension Tom Lane <[email protected]>
  2022-06-03 17:05   ` Re: Proposal to improve uniq function documentation in intarray extension Daniel Gustafsson <[email protected]>
  2022-06-03 17:55     ` Re: Proposal to improve uniq function documentation in intarray extension Tom Lane <[email protected]>
@ 2022-06-07 08:48       ` Martin Kalcher <[email protected]>
  0 siblings, 0 replies; 5+ messages in thread

From: Martin Kalcher @ 2022-06-07 08:48 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; Daniel Gustafsson <[email protected]>; +Cc: [email protected]

Thank you very much. The new documentation is way better.

Am 03.06.22 um 19:55 schrieb Tom Lane:
> Daniel Gustafsson <[email protected]> writes:
>>> On 3 Jun 2022, at 17:34, Tom Lane <[email protected]> wrote:
>>> .. there's no longer any reason we have
>>> to limit ourselves to one example.  I propose this:
> 
>> +1
> 
> Done like that, then.
> 
> 			regards, tom lane






^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2022-06-07 08:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-06-01 10:20 Proposal to improve uniq function documentation in intarray extension PG Doc comments form <[email protected]>
2022-06-03 15:34 ` Tom Lane <[email protected]>
2022-06-03 17:05   ` Daniel Gustafsson <[email protected]>
2022-06-03 17:55     ` Tom Lane <[email protected]>
2022-06-07 08:48       ` Martin Kalcher <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox