Row pattern recognition - Mailing list pgsql-hackers

From David G. Johnston
Subject Row pattern recognition
Date
Msg-id CAKFQuwatcdJaTz-TndQtc21JhgVzOCtZuatSAxD=cpnBLY1L+w@mail.gmail.com
Whole thread Raw
In response to Re: Row pattern recognition  (Tatsuo Ishii <ishii@postgresql.org>)
Responses Re: Row pattern recognition
List pgsql-hackers
On Monday, October 21, 2024, Tatsuo Ishii <ishii@postgresql.org> wrote:
I wonder how "PREV(col + 1)" is different from "PREV(col) + 1".
Currently my RPR implementation does not allow PREV(col + 1). If
"PREV(col + 1)" is different from "PREV(col) + 1", it maybe worthwhile
to implement "PREV(col + 1)".

Interesting feature that I’m now just seeing.

The expression PREV(column_name) produces a value output taken from the given named column in the preceding frame row.  It doesn’t make any sense to me to attempt to add the integer 1 to an identifier that is being used as a value input to a “function”.  It would also seem quite odd if “+ 1” had something to do with row selection as opposed to simply being an operator “+(column_name%type, integer)” expression.

Maybe RPR is defining something special here I haven't yet picked up on, in which case just ignore this.  But if I read: “UP as price > prev(price + 1)” in the opening example it would be quite non-intuitive to reason out the meaning.  “Price > prev(price) + 1” would mean my current row is at least one (e.g. dollar per share) more than the value of the previous period.

David J.

pgsql-hackers by date:

Previous
From: Tatsuo Ishii
Date:
Subject: Re: Row pattern recognition
Next
From: "Andrey M. Borodin"
Date:
Subject: Re: Using read_stream in index vacuum