Skip to content
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

Update MaxUpperBound when inserting into RangeTree #2146

Merged
merged 3 commits into from
Nov 16, 2023
Merged

Update MaxUpperBound when inserting into RangeTree #2146

merged 3 commits into from
Nov 16, 2023

Conversation

jycor
Copy link
Contributor

@jycor jycor commented Nov 16, 2023

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 during FindConnection(). 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.

Copy link
Contributor

@Hydrocharged Hydrocharged left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@max-hoffman max-hoffman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, very subtle bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants