-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deeply recursive UNION queries cause stack overflow #9373
Comments
take |
I believe there are two ways to fully resolve this issue:
I will go with the first option, because it was suggested by @alamb, but open to discussing this further if needed 🙂 |
I agree -- stuff like `rebelssive' (and stacker is another) seem to me like a workaround for a more fundamental algorithmic design issue. Thank you for taking this on @blaginin |
Just wanted to share my thoughts on the task before I bombard you with PRs 😅 I think Once this is done, we will need to implement either of those two traits for Because Hence, I think I see two options for that:
pub enum MaybeBarren<T> {
Present(T),
// node has been destructed, but can be re-constructed when we get its children
Barren(Box<dyn FnOnce(Vec<T>) -> Result<T>>),
} There will still be some struct and methods changes, but probably less than in the option one. But then it will be harder to implement functions like |
I do think that has been brought up many times before. Now that we have a better infrastructure for rewriting plans without forcing copies I think it might make more sense than it did previously (where we had to have relatively cheap LogicalPlan::clone) |
Describe the bug
In InfluxDB we sometimes create deeply nested queries like this that cause a stack overflow, even in release builds:
To Reproduce
Download: blowout.zip
And run
This results in
andrewlamb@Andrews-MacBook-Pro Downloads % datafusion-cli -f blowout.sql datafusion-cli -f blowout.sql DataFusion CLI v36.0.0 thread 'main' has overflowed its stack fatal runtime error: stack overflow
The query looks like this
Expected behavior
a runtime error rather than stack overflow. Bonus points if the query actually completed
Additional context
It may be possible to change the treenode recursion to use an iterative approach rather than a recursive one (aka keep a worklist), much as we did in the sql parser to protect against deeply nested expressions
Note it is important to use a release build (as the debug build fails earlier in the process)
In a release build, the stack looks like this:
The text was updated successfully, but these errors were encountered: