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

sql/schemachanger/scplan/internal/rules: rework dep rules #82256

Merged
merged 2 commits into from
Jun 6, 2022

Conversation

ajwerner
Copy link
Contributor

@ajwerner ajwerner commented Jun 1, 2022

The dep rules helpers were brittle. Instead, make it easier to construct rel
queries directly.

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@ajwerner ajwerner force-pushed the ajwerner/rework-dep-rules branch from 05e335b to ad72e44 Compare June 1, 2022 16:57
@ajwerner ajwerner marked this pull request as ready for review June 1, 2022 16:57
@ajwerner ajwerner requested review from a team and postamar June 1, 2022 16:57
Copy link
Contributor

@postamar postamar left a comment

Choose a reason for hiding this comment

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

LGTM, I like it and it's simpler.

joinOnIndexID(from, to),
targetStatusEq(fromTarget, toTarget, scpb.ToAbsent),
currentStatusEq(fromNode, toNode, scpb.Status_ABSENT),
rel.Filter("secondaryIndexPartialIsNotBeingDropped", from)(func(
Copy link
Contributor

@postamar postamar Jun 1, 2022

Choose a reason for hiding this comment

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

Kebab-case all the rel string literals?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made the filter functions camelCase. I'm starting to dislike the kebabs. If I were typing this language I would not be pleased with kabobs I don't think. Sometimes I think about what an interpreter would look like. I'm going to keep iterating around these parts, happy to make further changes later.

func(from, fromTarget, fromNode, to, toTarget, toNode rel.Var) rel.Clauses {
return rel.Clauses{
from.Type((*scpb.TemporaryIndex)(nil)),
to.Type((*scpb.PrimaryIndex)(nil), (*scpb.SecondaryIndex)(nil)),
Copy link
Contributor

Choose a reason for hiding this comment

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

I wish there was a way to make these type unions pop out more systematically somehow. It's why I originally newlined each subtype, I found that it helped readability. I think this is fine though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@ajwerner ajwerner force-pushed the ajwerner/rework-dep-rules branch from ad72e44 to 2aaa4fe Compare June 1, 2022 23:14
@ajwerner
Copy link
Contributor Author

ajwerner commented Jun 2, 2022

both the builds are certified flakes

bors r+

@craig
Copy link
Contributor

craig bot commented Jun 2, 2022

Build failed:

@ajwerner
Copy link
Contributor Author

ajwerner commented Jun 3, 2022

bors r+

@craig
Copy link
Contributor

craig bot commented Jun 3, 2022

Build failed:

Before this change, an index which had it conditions met could be used even if
the input query did not constrain the index at all. We never want this to be
the case for queries we use; we should always be able to constrain the database
at least a little. This rule caught a bug that made logic tests slow. I think
it'll be very handy.

Note that as a special case, an index which indexes not columns permits any
scan. This is useful for testing the logic of the library.

Release note: None
@ajwerner ajwerner force-pushed the ajwerner/rework-dep-rules branch from 2aaa4fe to 9874591 Compare June 6, 2022 05:34
The dep rules helpers were brittle. Instead, make it easier to construct rel
queries directly.

Release note: None
@ajwerner ajwerner force-pushed the ajwerner/rework-dep-rules branch from 9874591 to e5ee890 Compare June 6, 2022 14:46
@ajwerner
Copy link
Contributor Author

ajwerner commented Jun 6, 2022

@postamar I added a new first commit to this which, in retrospect, is an important one. There was a buglet where we'd say that an index can be used even if it matches none of the attributes. This lead to the possibility of writing rules which would not be index accelerated. The hope is to always index accelerate rule evaluation. The immediately caught the bug which lead to the change making logic tests slow. PTAL before I bors it.

@ajwerner
Copy link
Contributor Author

ajwerner commented Jun 6, 2022

I'm going to bors it.

bors r+

@craig
Copy link
Contributor

craig bot commented Jun 6, 2022

Build succeeded:

@craig craig bot merged commit 1860eaa into cockroachdb:master Jun 6, 2022
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