-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
schemachanger: support partition zone config #130422
Conversation
96b61fa
to
7041bb6
Compare
pkg/ccl/logictestccl/testdata/logic_test/multi_region_zone_configs
Outdated
Show resolved
Hide resolved
f4d835e
to
c4bd018
Compare
Your pull request contains more than 1000 changes. It is strongly encouraged to split big PRs into smaller chunks. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
argh -- i think i need to review over the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look okay to me. I just had a few questions in the code.
Reviewed 2 of 4 files at r1, 24 of 24 files at r5, 2 of 2 files at r6, 10 of 10 files at r7, 5 of 5 files at r8, 5 of 5 files at r9, 3 of 3 files at r10, 17 of 17 files at r11, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @annrpom)
pkg/sql/schemachanger/scbuild/internal/scbuildstmt/partition_zone_config.go
line 80 at r10 (raw file):
partitionName := string(zs.Partition) // TODO(before merge): [reviewer callout] can we guarantee that this will
Would it be safer to check both cases by calling isCorrespondingTemporaryIndex
twice—once assuming the temporary index is indexes[0]
and again assuming it’s indexes[1]
?
pkg/sql/schemachanger/scbuild/internal/scbuildstmt/zone_config_helpers.go
line 1171 at r10 (raw file):
maybeCorresponding := b.QueryByID(tableID).FilterTemporaryIndex(). Filter(func(_ scpb.Status, _ scpb.TargetStatus, e *scpb.TemporaryIndex) bool { return idx+1 == e.IndexID && e.IndexID == otherIdx
Isn’t idx
the ID of the temporary index? Since e
is a temporary index based on the filter, shouldn’t the check be:
return idx == e.IndexID && e.IndexID == otherIdx+1
pkg/sql/schemachanger/scop/immediate_mutation.go
line 936 at r8 (raw file):
TableID descpb.ID IndexID descpb.IndexID PartitionName string
I didn’t see this field being used. Do we need to pass it down when calling UpdateSubzoneConfig
?
pkg/ccl/logictestccl/testdata/logic_test/zone
line 1308 at r9 (raw file):
statement ok CREATE TABLE fooba(pk INT PRIMARY KEY, i INT); ALTER TABLE fooba PARTITION BY LIST (pk) (PARTITION "one" VALUES IN (1), PARTITION "rest" VALUES IN (DEFAULT));
Should we separate this into a new statement so that we run this through the DSC?
pkg/sql/schemachanger/scbuild/internal/scbuildstmt/partition_zone_config.go
Outdated
Show resolved
Hide resolved
pkg/sql/schemachanger/scbuild/internal/scbuildstmt/partition_zone_config.go
Outdated
Show resolved
Hide resolved
pkg/sql/schemachanger/scbuild/internal/scbuildstmt/zone_config_helpers.go
Outdated
Show resolved
Hide resolved
c4bd018
to
a9669ff
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @fqazi and @spilchen)
pkg/sql/schemachanger/scbuild/internal/scbuildstmt/partition_zone_config.go
line 80 at r10 (raw file):
Previously, spilchen wrote…
Would it be safer to check both cases by calling
isCorrespondingTemporaryIndex
twice—once assuming the temporary index isindexes[0]
and again assuming it’sindexes[1]
?
ah i think this would also work; i think the logic would look a bit messier -- i'm thinking something like:
case 2:
// Perhaps our target index is a part of a backfill. In this case,
// temporary indexes created during backfill should always share the
// same zone configs as the corresponding new index.
idx1 := indexes[0]
idx2 := indexes[1]
hasIdx2AsTemp := isCorrespondingTemporaryIndex(b, pzo.tableID, idx2.IndexID, idx1.IndexID)
hasIdx1AsTemp := isCorrespondingTemporaryIndex(b, pzo.tableID, idx1.IndexID, idx2.IndexID)
if hasIdx2AsTemp || hasIdx1AsTemp {
idx := idx1
if hasIdx1AsTemp {
idx = idx2
}
idxName := mustRetrieveIndexNameElem(b, pzo.tableID, idx.IndexID)
zs.TableOrIndex.Index = tree.UnrestrictedName(idxName.Name)
// Our index name has changed -- find the corresponding indexID
// and fill that out.
pzo.fillIndexFromZoneSpecifier(b, n.ZoneSpecifier)
break
}
since the array len will always be 2, i think i'll sort our indexes by ID before calling isCorrespondingTemporaryIndex
, but i'm open to further discussion
pkg/sql/schemachanger/scbuild/internal/scbuildstmt/partition_zone_config.go
line 334 at r11 (raw file):
Previously, fqazi (Faizan Qazi) wrote…
I think in for most cases this would be true, but I don't think its guaranteed it would be true in more complex cases. I think to be safer we can gather all the partitions and sort them by IndexID, the iteration order matches the the order things are added in the builder.
ah right; ty
pkg/sql/schemachanger/scbuild/internal/scbuildstmt/partition_zone_config.go
line 339 at r11 (raw file):
Previously, fqazi (Faizan Qazi) wrote…
Do we need to look at the current status or target here? This will include dropping objects as well right now.
done
pkg/sql/schemachanger/scbuild/internal/scbuildstmt/zone_config_helpers.go
line 1171 at r10 (raw file):
Previously, spilchen wrote…
Isn’t
idx
the ID of the temporary index? Sincee
is a temporary index based on the filter, shouldn’t the check be:return idx == e.IndexID && e.IndexID == otherIdx+1
done -- ty!
pkg/sql/schemachanger/scbuild/internal/scbuildstmt/zone_config_helpers.go
line 1175 at r11 (raw file):
Previously, fqazi (Faizan Qazi) wrote…
Think you need to use the TemporaryIndexID field here
done -- ty!
pkg/sql/schemachanger/scop/immediate_mutation.go
line 936 at r8 (raw file):
Previously, spilchen wrote…
I didn’t see this field being used. Do we need to pass it down when calling
UpdateSubzoneConfig
?
no we do not -- we don't need to pass down indexID either technically (same for AddIndexZoneConfig
); let me fix the partitions one in this pr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @fqazi and @spilchen)
pkg/ccl/logictestccl/testdata/logic_test/zone
line 1308 at r9 (raw file):
Previously, spilchen wrote…
Should we separate this into a new statement so that we run this through the DSC?
oki done
This patch adds a new element, `PartitionZoneConfig`, that will become relevant for supporting `ALTER PARTITION ... CONFIGURE ZONE` in the DSC. Release note: None
a9669ff
to
4d1cd3f
Compare
This patch adds an opgen rule to support our PartitionZoneConfig element. Release note: None
This patch ensures that we panic if a partition does not exist on the specified index in a `ALTER TABLE ... OF INDEX`. Release note: None
This patch adds support for ALTER PARTITION ... OF TABLE in the form of zone_config_helpers. Release note: None
4d1cd3f
to
866d217
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 10 files at r7, 16 of 31 files at r12, 32 of 32 files at r17, 5 of 5 files at r18, 1 of 3 files at r20, 26 of 28 files at r21, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @annrpom and @spilchen)
pkg/sql/schemachanger/scbuild/internal/scbuildstmt/zone_config_helpers.go
line 1164 at r21 (raw file):
b BuildCtx, tableID catid.DescID, idx catid.IndexID, otherIdx catid.IndexID, ) bool { maybeCorresponding := b.QueryByID(tableID).FilterTemporaryIndex().
Think we can check TemporaryIndexID in here too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 5 of 31 files at r12, 2 of 29 files at r16, 32 of 32 files at r17, 1 of 5 files at r19, 2 of 28 files at r21, all commit messages.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @annrpom and @fqazi)
pkg/sql/schemachanger/scbuild/internal/scbuildstmt/partition_zone_config.go
line 80 at r10 (raw file):
Previously, annrpom (annie pompa) wrote…
ah i think this would also work; i think the logic would look a bit messier -- i'm thinking something like:
case 2: // Perhaps our target index is a part of a backfill. In this case, // temporary indexes created during backfill should always share the // same zone configs as the corresponding new index. idx1 := indexes[0] idx2 := indexes[1] hasIdx2AsTemp := isCorrespondingTemporaryIndex(b, pzo.tableID, idx2.IndexID, idx1.IndexID) hasIdx1AsTemp := isCorrespondingTemporaryIndex(b, pzo.tableID, idx1.IndexID, idx2.IndexID) if hasIdx2AsTemp || hasIdx1AsTemp { idx := idx1 if hasIdx1AsTemp { idx = idx2 } idxName := mustRetrieveIndexNameElem(b, pzo.tableID, idx.IndexID) zs.TableOrIndex.Index = tree.UnrestrictedName(idxName.Name) // Our index name has changed -- find the corresponding indexID // and fill that out. pzo.fillIndexFromZoneSpecifier(b, n.ZoneSpecifier) break }
since the array len will always be 2, i think i'll sort our indexes by ID before calling
isCorrespondingTemporaryIndex
, but i'm open to further discussion
Yeah, I'm okay with sorting. It keeps the code clean.
This patch adds the functionality to configure a zone configuration on a partition. Fixes: cockroachdb#129889 Release note: None
866d217
to
f2f059d
Compare
TFTR! ('-')7 bors r+ |
schemachanger: add PartitionZoneConfig element
This patch adds a new element,
PartitionZoneConfig
,that will become relevant for supporting
ALTER PARTITION ... CONFIGURE ZONE
in the DSC.Release note: None
schemachanger: add opgen rule for partition zc
This patch adds an opgen rule to support our PartitionZoneConfig
element.
Release note: None
schemachanger: panic if partition does not exist on index
This patch ensures that we panic if a partition does not
exist on the specified index in a
ALTER TABLE ... OF INDEX
.Release note: None
schemachanger: add support for ALTER PARTITION ... OF TABLE
This patch adds support for ALTER PARTITION ... OF TABLE in
the form of zone_config_helpers.
Release note: None
schemachanger: support partition zone config
This patch adds the functionality to configure
a zone configuration on a partition.
Fixes: #129889
Release note: None
Epic: CRDB-31473