Re: BUG #19340: Wrong result from CORR() function

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Oleg Ivanov <o15611(at)gmail(dot)com>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19340: Wrong result from CORR() function
Date: 2025-12-02 23:48:28
Message-ID: CAEZATCWh-uat8qqyWgJL0gU6ukrYHc9rzmMXKkc5+99yv0-a_Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, 2 Dec 2025 at 23:24, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> writes:
> > I played around with having just 2 extra array elements, constX and
> > constY equal to the common value if all the values are the same, and
> > NaN otherwise.
>
> Hmm.
>
> > Doing it that way does lead to one difference though: all-NaN inputs
> > leads to a NaN result, whereas your patch produces NULL for that case.
>
> Yeah, I did it as I did precisely because I wanted all-NaN-input to be
> seen as a constant. But you could make an argument that NaN is not
> really a fixed value but has more kinship to the "we don't know what
> the value is" interpretation of SQL NULL.

I think that's more consistent with the general policy that most
(all?) math functions have, where if any input is NaN, the result is
NaN.

Regards,
Dean

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2025-12-03 00:17:32 Re: BUG #19340: Wrong result from CORR() function
Previous Message Tom Lane 2025-12-02 23:24:20 Re: BUG #19340: Wrong result from CORR() function