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

Improve how index lookups and ranges address NULL values. #1078

Merged
merged 20 commits into from
Jun 28, 2022

Conversation

reltuk
Copy link
Contributor

@reltuk reltuk commented Jun 24, 2022

No description provided.

reltuk and others added 6 commits June 22, 2022 16:42
Print lower bound AboveAll as (∞.

Make IsEmpty return true is Lower >= Upper.

Make RangeTree.GetRangeCollection() merge adjacent ranges on return.

Make IndexBuilder exclude superfluous empty ranges.
…ilding static lookups that can actually match NULL.
Copy link
Contributor

@andy-wm-arthur andy-wm-arthur left a comment

Choose a reason for hiding this comment

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

LGTM

rangeColumnExpr = expression.NewNullSafeLessThan(idx.Exprs[i], expression.NewLiteral(lit, typ))
rangeColumnExpr = or(
expression.NewLessThan(idx.Exprs[i], expression.NewLiteral(lit, typ)),
expression.NewIsNull(idx.Exprs[i]),
Copy link
Contributor

Choose a reason for hiding this comment

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

select * from t where c0 < 3 does not return nulls, so I'm assuming it doesn't get translated to a RangeType_LessThan

"github.com/stretchr/testify/assert"
)

func TestIndexBuilderRanges(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

you should add a LT4=(NULL,4)

return RangeColumnExpr{
BelowAll{},
AboveNull{},
Copy link
Contributor

Choose a reason for hiding this comment

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

+1

@reltuk reltuk marked this pull request as ready for review June 24, 2022 23:08
@reltuk reltuk merged commit 16e266a into main Jun 28, 2022
@Hydrocharged Hydrocharged deleted the aaron/sql-ranges-add-above-below-null branch October 13, 2022 12:51
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.

2 participants