-
Notifications
You must be signed in to change notification settings - Fork 155
Fix: Long IN-lists causes crash #3660
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
Fix: Long IN-lists causes crash #3660
Conversation
Signed-off-by: Simeon Widdis <[email protected]>
Signed-off-by: Simeon Widdis <[email protected]>
The "end - start < 1" case shouldn't ever be reached, but we can still code defensively if the case is hit. The result might not be well-defined but it at least won't crash the whole JVM. Signed-off-by: Simeon Widdis <[email protected]>
878b31a
to
da3e941
Compare
Signed-off-by: Simeon Widdis <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix. In original issue, one of the possible solution is
"Compile IN expression to field = ANY(ARRAY(values)) which maybe optimal at both compile and runtime"
Could you compare it with current approach?
I wrote it in the description
It would probably be better than this, but it looks like we don't already have a I know from the |
Will this improving be a throw away work in future? This issue only happens in v2. And with calcite, the query
instead of following in v2:
+1 for |
Description
Per #1469, very large lists of expressions in IN clauses cause
StackOverflowError
s. Avoiding all recursion here is nontrivial becauseDSL.or
can only take two arguments (and is internally implemented as a LUT for performance). This PR instead rewrites the method to have the recursion amount grow logarithmically, by building theor
tree as a balanced tree. This avoids hitting any recursion limits unless there's well over 2⁵¹² items in the list.Implementing something like
DSL.any
is on the table for future work if we need to optimize further, but it's more complex than this fix and it's not clear that this is a hot path.Related Issues
Resolves #1469
Check List
--signoff
.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.