Update MaxUpperBound
when inserting into RangeTree
#2146
Merged
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.
Recent changes to index costing exposed a bug in
RangeTree
. This bug is responsible for a small regression in the sqllogictests, involving a complicated filter.When generating ranges over an index to satisfy a filter, we have to ensure that the resulting ranges do not overlap; we accomplish this efficiently through the use of a RangeTree (a multi-dimensional red-black tree) to split up and merge ranges.
Given a Range, the RangeTree returns a set of Ranges that overlap it, and we replace these with a set of ranges that cover the same area, minus the overlap.
However, during insertion (specifically when the new node is a right child), we do not update the parent's
MaxUpperBound
. This is important for deciding to search subtrees duringFindConnection()
. As a result, the RangeTree did not find all overlapping ranges, and would produce a set of Ranges that still contained overlaps.Additionally, this PR adds a slightly better method of checking if the resulting ranges have overlaps.
There is also a skipped test; it's possible that there are multiple sets of non overlapping ranges that satisfy the same sets of filters.
There will be a follow up PR that has a better method of verifying the correctness of these ranges.