Switch to non-recursive on heap virtual stack when building logical plan from SQL expression#6360
Merged
alamb merged 5 commits intoapache:mainfrom May 18, 2023
Merged
Conversation
alamb
approved these changes
May 17, 2023
Contributor
alamb
left a comment
There was a problem hiding this comment.
Thank you very much @aprimadi . This is really neat.
I guess the next level would be to thread the stack machine down to parsing all expressions (not just binary ops) which while would make the code more uniform I am not sure it would make it easier to understand
Not sure why anyone would want more than 256 expressions
LOL I think this kind of expression is generated by other programs / tools like BI frontends
| }; | ||
| } | ||
|
|
||
| test_stack_overflow!(64); |
Contributor
There was a problem hiding this comment.
I verified that without the code in this PR, the tests fail as expected:
running 14 tests
test expr::arrow_cast::test::test_parse_data_type_whitespace_tolerance ... ok�(B
test expr::identifier::test::test_form_identifier ... ok�(B
test expr::identifier::test::test_generate_schema_search_terms ... ok�(B
test expr::arrow_cast::test::parse_data_type_errors ... ok�(B
test expr::arrow_cast::test::test_parse_data_type ... ok�(B
test parser::tests::create_external_table ... ok�(B
test expr::tests::test_stack_overflow_64 ... ok�(B
test expr::tests::test_stack_overflow_128 ... ok�(B
test expr::tests::test_stack_overflow_256 ... ok�(B
test expr::tests::test_stack_overflow_512 ... ok�(B
thread 'expr::tests::test_stack_overflow_1024' has overflowed its stack
fatal runtime error: stack overflow
error: test failed, to rerun pass `-p datafusion-sql --lib`
Caused by:
process didn't exit successfully: `/Users/alamb/Software/target-df2/debug/deps/datafusion_sql-8a77caa8d397a04b` (signal: 6, SIGABRT: process abort signal)
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
Contributor
|
Thanks again @aprimadi |
Contributor
Author
|
Thank you @alamb for the review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Closes #6040
Closes #1444
Closes #1434
Rationale for this change
Not sure why anyone would want more than 256 expressions but I thought I would write the iterative version just for fun. Now users can write all the expressions they want (or at least until the generated
Exprcan no longer fit in the stack).Kudos to @alamb and @houqp for suggesting this iterative version.
What changes are included in this PR?
Are these changes tested?
Yes. Tested by existing tests. Also added a few stack overflow tests.
Are there any user-facing changes?
No