Does anyone know if SQL Standards define and PostgreSQL will implement (10.x or higher) Parametric Window Size?
Bellow a MVE of what I call a parametric window size:
WITH
D AS (SELECT T.x::FLOAT FROM generate_series(0., 10., 0.1) AS T(x)),
W AS (SELECT 10 AS WindowSize)
SELECT
D.x
,AVG(D.x) OVER (ROWS BETWEEN W.WindowSize PRECEDING AND CURRENT ROW)
FROM
D, W;
Which raises the following error:
ERROR: argument of ROWS must not contain variables
LINE 8: ,AVG(D.x) OVER (ROWS BETWEEN W.WindowSize PRECEDING AND C...
^
********** Error **********
ERROR: argument of ROWS must not contain variables
SQL State: 42P10
I understand parametric window is kind of complex to implement. And I know that I can bypass some aspects of this limitation using Dynamic Query and PL/PGSQL.
My questions are:
- Do SQL Standards define such a thing?
- Will PostgreSQL implement it (if so, when is it planned)?
- If not, what are limitations to overcome before having such a feature?
ROWS. It is pretty easy to get the functionality in other ways, but that is not your question.