Skip to content

Internal Error in APPROX_PERCENTILE_CONT window function (SQLancer) #12058

Closed

Description

@2010YOUY01

Describe the bug

Using APPROX_PERCENTILE_CONT() aggregate as window function is supported now, but under certain case an internal error will be triggered.

See reproducer in datafusion-cli (compiled from latest main, commit is 574dfeb)

DataFusion CLI v41.0.0
> create table t1(v1 int);
insert into t1 values (1),(2),(3),(4),(5);
0 row(s) fetched.
Elapsed 0.108 seconds.

+-------+
| count |
+-------+
| 5     |
+-------+
1 row(s) fetched.
Elapsed 0.049 seconds.

> SELECT
  APPROX_PERCENTILE_CONT(v1, 0.5) OVER (
    ROWS BETWEEN 4 PRECEDING AND CURRENT ROW
  )
FROM
  t1;
+-------------------------------------------------------------------------------------+
| approx_percentile_cont(t1.v1,Float64(0.5)) ROWS BETWEEN 4 PRECEDING AND CURRENT ROW |
+-------------------------------------------------------------------------------------+
| 1                                                                                   |
| 1                                                                                   |
| 2                                                                                   |
| 2                                                                                   |
| 3                                                                                   |
+-------------------------------------------------------------------------------------+
5 row(s) fetched.
Elapsed 0.040 seconds.

> insert into t1 values (6);
+-------+
| count |
+-------+
| 1     |
+-------+
1 row(s) fetched.
Elapsed 0.003 seconds.

> SELECT
  APPROX_PERCENTILE_CONT(v1, 0.5) OVER (
    ROWS BETWEEN 4 PRECEDING AND CURRENT ROW
  )
FROM
  t1;
Internal error: Retract should be implemented for aggregate functions when used with custom window frame queries.
This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker

To Reproduce

No response

Expected behavior

No response

Additional context

Found by SQLancer #11030

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions