Skip to content

union all +aggregate function in the recursive cte results an infinite loop #1131

@l1t1

Description

@l1t1

Describe the bug
union all +aggregate function in the recursive cte results an infinite loop

To Reproduce
Steps to reproduce the behavior:

import datafusion
from datafusion import SessionContext

ctx = SessionContext()
df = ctx.sql("""
with recursive t as(select value i,1 lv from generate_series(1,6,1)
union all
select max(i),max(lv)+1 from t where lv<2)
select * from t where lv=2;
""")

>>> print(df)

Expected behavior
it outputs

DataFrame()
+---+----+
| i | lv |
+---+----+
| 6 | 2  |
+---+----+

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions