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

partitionccl: make CreatePartitioning idempotent for implicit columns #60696

Merged
merged 1 commit into from
Feb 18, 2021

Conversation

otan
Copy link
Contributor

@otan otan commented Feb 17, 2021

Previously, calling CreatePartitioning twice on an implicitly
partitioned index would un-implicitly partition that index. This commit
changes CreatePartitioning to not un-implicitly partition the index in
such a case.

Release note: None

@otan otan requested review from arulajmani and a team February 17, 2021 19:31
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@arulajmani arulajmani left a comment

Choose a reason for hiding this comment

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

Thanks for making this change!

Couple notes:

  • Can we add some tests in partitioning_implicit that test this stuff directly as well
  • Can we cleanup some of the complexity in alter_primary_key around altering to/from REGIONAL BY ROW tables? I'm thinking around here:
    // Detect partitioning if we are newly adding a PARTITION BY ALL statement.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @otan)


pkg/ccl/partitionccl/partition.go, line 394 at r1 (raw file):

			)
		}
		for i, oldColID := range oldImplicitColumnIDs {

Just confirming, we don't need to check for the direction of implicit columns right? There's now way that could change?

Copy link
Contributor Author

@otan otan left a comment

Choose a reason for hiding this comment

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

Can we add some tests in partitioning_implicit that test this stuff directly as well

What tests would do this? We block everywhere you try to change an implicitly partitioned column when using ALTER INDEX, and that's already tested.

Can we cleanup some of the complexity in alter_primary_key around altering to/from REGIONAL BY ROW tables? I'm thinking around here:

No, because in that case we are changing the implicitly partitioned columns to something else. But we are rewriting the index, so it's okay.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @arulajmani)


pkg/ccl/partitionccl/partition.go, line 394 at r1 (raw file):

Previously, arulajmani (Arul Ajmani) wrote…

Just confirming, we don't need to check for the direction of implicit columns right? There's now way that could change?

Nope -- all implicitly partitioned column is ascending

Copy link
Collaborator

@arulajmani arulajmani left a comment

Choose a reason for hiding this comment

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

We block everywhere you try to change an implicitly partitioned column when using ALTER INDEX

I see, I guess I was under the impression that this would no-op and we could test that. I don't think we need to do that in this patch, I'm fine with this as is.

No, because in that case we are changing the implicitly partitioned columns to something else. But we are rewriting the index, so it's okay.
I don't know this code quite well, but the comment says

		// column descriptor in front of each index, and calling CreatePartitioning again
		// will make these indexes explicit.

The "CreatePartitioning again will make indexes explicit" no longer applies, right? Can't we clean this up?

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @arulajmani)

@otan
Copy link
Contributor Author

otan commented Feb 17, 2021

The "CreatePartitioning again will make indexes explicit" no longer applies, right? Can't we clean this up?

I see, yes, but that is now needed regardless for the REGIONAL BY ROW -> REGIONAL BY ROW case.

@otan otan force-pushed the idempotent_cp branch 2 times, most recently from f549667 to 45ae81b Compare February 17, 2021 23:08
Previously, calling CreatePartitioning twice on an implicitly
partitioned index would un-implicitly partition that index. This commit
changes CreatePartitioning to not un-implicitly partition the index in
such a case.

Release note: None
@otan
Copy link
Contributor Author

otan commented Feb 18, 2021

bors r=arulajmani

@craig
Copy link
Contributor

craig bot commented Feb 18, 2021

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Feb 18, 2021

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Feb 18, 2021

Build succeeded:

@craig craig bot merged commit 3c223f5 into cockroachdb:master Feb 18, 2021
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