Skip to content

Enable recursive CTE support by default #9554

Closed
@alamb

Description

@alamb

Is your feature request related to a problem or challenge?

As part of #462, @matthewgapp implemented support for recursive Common Table Expressions (aka Recursive CTEs)

Here is an example of such a query:

https://github.com/apache/arrow-datafusion/blob/4cd3c433004a7a6825643d6b3911db720efe5f76/datafusion/sqllogictest/test_files/cte.slt#L44-L68

At the moment, to use recursive CTEs you must enable a config option:

set datafusion.execution.enable_recursive_ctes = true;

Describe the solution you'd like

I would like recursive CTEs to be enabled by default (and thus useable without a config option)

The only reason I know of at the moment that they are NOT enabled by default is because they might buffer an infinite amount of data (and thus exceed the total memory available to DataFusion)

Describe alternatives you've considered

I think the basic idea would be to

  1. Extend RecursiveQueryExec with a MemoryReservation
  2. Track the memory of any buffered batches, erroring if they can not be buffered
  3. Write a test in memory_limit.rs showing the limit being hit: https://github.com/apache/arrow-datafusion/blob/main/datafusion/core/tests/memory_limit.rs
  4. Change the default value of

The main PR that added this feature was #8840

Additional context

No response

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions