Skip to content

Sliding window execution fails for covar_pop, covar_samp, and corr #22763

@pchintar

Description

@pchintar

Describe the bug

Bounded sliding window queries using covar_pop, covar_samp, and corr fail with a "retract_batch is not implemented" error, even though these aggregates otherwise work correctly.

To Reproduce

CREATE TABLE sliding_corr_test AS
VALUES
  (1, 10.0),
  (2, 20.0),
  (3, 30.0);

SELECT
  column1,
  covar_pop(column2, column2) OVER (
    ORDER BY column1
    ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING
  ) AS cp,
  covar_samp(column2, column2) OVER (
    ORDER BY column1
    ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING
  ) AS cs,
  corr(column2, column2) OVER (
    ORDER BY column1
    ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING
  ) AS c
FROM sliding_corr_test;

Expected behavior

The query should execute successfully and return covariance/correlation values for the specified window frame, similar to how other aggregates that support bounded sliding windows behave.

Actual Result

This feature is not implemented: Aggregate can not be used as a sliding accumulator because `retract_batch` is not implemented: covar_pop(sliding_corr_test.column2, sliding_corr_test.column2) ORDER BY [sliding_corr_test.column1 ASC NULLS LAST] ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING

The same error occurs for other bounded sliding frames, for example:

ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions