Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
55558: opt: prove partial index implication in scanIndexIter r=mgartner a=mgartner

This commit updates `scanIndexIter` in order to make it safer to reduce
filters during partial index implication. The goal is to help avoid the
common mistake of using filters for an enumerated index that were
reduced in a previous iteration. Another benefit of these changes is
that code for checking filter/predicate implication has been
de-duplicated and moved into `scanIndexIter`.

The `Next` and for-loop iteration pattern has been replaced with a
`ForEach` and callback pattern. Partial indexes are only enumerated if
their partial indexes are implied by the provided filters. Filters
reduced during partial index implication are passed to the callback
function.

`HasInvertedIndexes` and `canMaybeConstrainIndexWithCols` previously
used the `scanIndexIter` for simple iteration. They no longer do to
avoid over complicating the `scanIndexIter` with features to halt
iteration and ignore partial index implication.

Release note: None

55562: sql: remove TimeTZ and Time Precision 19.2->20.1 gates r=arulajmani a=otan

Refs #47447 

Release note: None

55615: util: fix metamorphic build tag r=jordanlewis a=jordanlewis

Prevously, the build tag for when metamorphic was set to on was
misconfigured.

Release note: None

Co-authored-by: Marcus Gartner <[email protected]>
Co-authored-by: Oliver Tan <[email protected]>
Co-authored-by: Jordan Lewis <[email protected]>
  • Loading branch information
4 people committed Oct 15, 2020
4 parents 6af3968 + 4eeae0a + 2c69b6a + a1b5148 commit c7eabc9
Show file tree
Hide file tree
Showing 5 changed files with 257 additions and 391 deletions.
16 changes: 0 additions & 16 deletions pkg/sql/create_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ type createTableRun struct {
// minimumTypeUsageVersions defines the minimum version needed for a new
// data type.
var minimumTypeUsageVersions = map[types.Family]clusterversion.VersionKey{
types.TimeTZFamily: clusterversion.VersionTimeTZType,
types.GeographyFamily: clusterversion.VersionGeospatialType,
types.GeometryFamily: clusterversion.VersionGeospatialType,
types.Box2DFamily: clusterversion.VersionBox2DType,
Expand All @@ -95,21 +94,6 @@ func isTypeSupportedInVersion(v clusterversion.ClusterVersion, t *types.T) (bool
t = t.ArrayContents()
}

switch t.Family() {
case types.TimeFamily, types.TimestampFamily, types.TimestampTZFamily, types.TimeTZFamily:
if t.Precision() != 6 && !v.IsActive(clusterversion.VersionTimePrecision) {
return false, nil
}
case types.IntervalFamily:
itm, err := t.IntervalTypeMetadata()
if err != nil {
return false, err
}
if (t.Precision() != 6 || itm.DurationField != types.IntervalDurationField{}) &&
!v.IsActive(clusterversion.VersionTimePrecision) {
return false, nil
}
}
minVersion, ok := minimumTypeUsageVersions[t.Family()]
if !ok {
return true, nil
Expand Down
45 changes: 1 addition & 44 deletions pkg/sql/create_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,50 +31,7 @@ func TestIsTypeSupportedInVersion(t *testing.T) {

ok bool
}{
{clusterversion.Version19_2, types.Time, true},
{clusterversion.Version19_2, types.Timestamp, true},
{clusterversion.Version19_2, types.Interval, true},

{clusterversion.Version19_2, types.TimeTZ, false},
{clusterversion.VersionTimeTZType, types.TimeTZ, true},

{clusterversion.Version19_2, types.MakeTime(0), false},
{clusterversion.Version19_2, types.MakeTimeTZ(0), false},
{clusterversion.VersionTimeTZType, types.MakeTimeTZ(0), false},
{clusterversion.Version19_2, types.MakeTimestamp(0), false},
{clusterversion.Version19_2, types.MakeTimestampTZ(0), false},
{
clusterversion.Version19_2,
types.MakeInterval(types.IntervalTypeMetadata{Precision: 3, PrecisionIsSet: true}),
false,
},
{
clusterversion.Version19_2,
types.MakeInterval(
types.IntervalTypeMetadata{
DurationField: types.IntervalDurationField{DurationType: types.IntervalDurationType_SECOND},
},
),
false,
},
{clusterversion.VersionTimePrecision, types.MakeTime(0), true},
{clusterversion.VersionTimePrecision, types.MakeTimeTZ(0), true},
{clusterversion.VersionTimePrecision, types.MakeTimestamp(0), true},
{clusterversion.VersionTimePrecision, types.MakeTimestampTZ(0), true},
{
clusterversion.VersionTimePrecision,
types.MakeInterval(types.IntervalTypeMetadata{Precision: 3, PrecisionIsSet: true}),
true,
},
{
clusterversion.VersionTimePrecision,
types.MakeInterval(
types.IntervalTypeMetadata{
DurationField: types.IntervalDurationField{DurationType: types.IntervalDurationType_SECOND},
},
),
true,
},
{clusterversion.VersionGeospatialType, types.Geometry, true},
}

for _, tc := range testCases {
Expand Down
Loading

0 comments on commit c7eabc9

Please sign in to comment.