Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
53145: colexec: add support for DISTINCT ordered aggregation r=yuzefovich a=yuzefovich **rowexec: speed up DISTINCT aggregation a bit** Previously, whenever we needed to clear `seen` map (which tracks the tuples we have already seen for the aggregation group), we would create a new map. However, it turns out that it is actually faster (according to micro-benchmarks) to delete all entries from the old map instead which is what this commit does. Release note: None **colexec: add support for DISTINCT ordered aggregation** This commit adds the support for DISTINCT ordered aggregation by reusing the same code (with minor modification to reset `seen` maps when the new group is encountered) as we have for hash aggregation. Quick benchmarks show about 6-7x improvement when comparing against a wrapped row-by-row processor. Closes: #39242. Release note (sql change): Vectorized execution now natively supports ordered aggregation with DISTINCT clause. 53154: sql: pass down index descriptors to stats generators r=mjibson a=mjibson This allows for geo indexes to have their first defined inverted index have its configuration be used when generating inverted index entries for histogram stats. Release note: None Fixes #52363 53216: colexec: fix recent problem with hash joiner r=yuzefovich a=yuzefovich #53169 has just introduced an optimization in populating of `toCheck` slice by having a default `hjInitialToCheck` slice pre-populated. However, it could be of insufficient length due to randomization of `coldata.BatchSize()` which is now fixed. Release note: None 53217: builtins: implement ST_IsEmpty and ST_IsCollection r=otan a=erikgrinaker `ST_IsCollection` does not handle `geopb.ShapeType_Geometry` in any special way, and will always return `false` - is this sufficient? Release note (sql change): Implement the geometry builtins `ST_IsEmpty` and `ST_IsCollection`. Closes #48954. Closes #48955. Co-authored-by: Yahor Yuzefovich <yahor@cockroachlabs.com> Co-authored-by: Matt Jibson <matt.jibson@gmail.com> Co-authored-by: Erik Grinaker <erik@grinaker.org>
- Loading branch information
Showing
20 changed files
with
787 additions
and
364 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2020 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package geomfn | ||
|
||
import ( | ||
"github.com/cockroachdb/cockroach/pkg/geo" | ||
"github.com/cockroachdb/cockroach/pkg/geo/geopb" | ||
) | ||
|
||
// IsCollection returns whether the given geometry is of a collection type. | ||
func IsCollection(g *geo.Geometry) (bool, error) { | ||
switch g.ShapeType() { | ||
case geopb.ShapeType_MultiPoint, geopb.ShapeType_MultiLineString, geopb.ShapeType_MultiPolygon, | ||
geopb.ShapeType_GeometryCollection: | ||
return true, nil | ||
default: | ||
return false, nil | ||
} | ||
} | ||
|
||
// IsEmpty returns whether the given geometry is empty. | ||
func IsEmpty(g *geo.Geometry) (bool, error) { | ||
return g.Empty(), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// Copyright 2020 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package geomfn | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/geo" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestIsCollection(t *testing.T) { | ||
testCases := []struct { | ||
wkt string | ||
expected bool | ||
}{ | ||
{"POINT(1.0 1.0)", false}, | ||
{"POINT EMPTY", false}, | ||
{"LINESTRING(1.0 1.0, 2.0 2.0)", false}, | ||
{"LINESTRING EMPTY", false}, | ||
{"POLYGON((0.0 0.0, 1.0 0.0, 1.0 1.0, 0.0 0.0))", false}, | ||
{"POLYGON EMPTY", false}, | ||
{"MULTIPOINT((1.0 1.0), (2.0 2.0))", true}, | ||
{"MULTIPOINT EMPTY", true}, | ||
{"MULTILINESTRING((1.0 1.0, 2.0 2.0, 3.0 3.0), (6.0 6.0, 7.0 6.0))", true}, | ||
{"MULTILINESTRING EMPTY", true}, | ||
{"MULTIPOLYGON(((3.0 3.0, 4.0 3.0, 4.0 4.0, 3.0 3.0)), ((0.0 0.0, 1.0 0.0, 1.0 1.0, 0.0 0.0), (0.1 0.1, 0.2 0.1, 0.2 0.2, 0.1 0.1)))", true}, | ||
{"MULTIPOLYGON EMPTY", true}, | ||
{"GEOMETRYCOLLECTION (POINT (40 10),LINESTRING (10 10, 20 20, 10 40))", true}, | ||
{"GEOMETRYCOLLECTION EMPTY", true}, | ||
{"GEOMETRYCOLLECTION (GEOMETRYCOLLECTION(POINT (40 10),LINESTRING (10 10, 20 20, 10 40)))", true}, | ||
{"GEOMETRYCOLLECTION (GEOMETRYCOLLECTION EMPTY)", true}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.wkt, func(t *testing.T) { | ||
g, err := geo.ParseGeometry(tc.wkt) | ||
require.NoError(t, err) | ||
ret, err := IsCollection(g) | ||
require.NoError(t, err) | ||
require.Equal(t, tc.expected, ret) | ||
}) | ||
} | ||
} | ||
|
||
func TestIsEmpty(t *testing.T) { | ||
testCases := []struct { | ||
wkt string | ||
expected bool | ||
}{ | ||
{"POINT(1.0 1.0)", false}, | ||
{"POINT EMPTY", true}, | ||
{"LINESTRING(1.0 1.0, 2.0 2.0)", false}, | ||
{"LINESTRING EMPTY", true}, | ||
{"POLYGON((0.0 0.0, 1.0 0.0, 1.0 1.0, 0.0 0.0))", false}, | ||
{"POLYGON EMPTY", true}, | ||
{"MULTIPOINT((1.0 1.0), (2.0 2.0))", false}, | ||
{"MULTIPOINT EMPTY", true}, | ||
{"MULTILINESTRING((1.0 1.0, 2.0 2.0, 3.0 3.0), (6.0 6.0, 7.0 6.0))", false}, | ||
{"MULTILINESTRING EMPTY", true}, | ||
{"MULTIPOLYGON(((3.0 3.0, 4.0 3.0, 4.0 4.0, 3.0 3.0)), ((0.0 0.0, 1.0 0.0, 1.0 1.0, 0.0 0.0), (0.1 0.1, 0.2 0.1, 0.2 0.2, 0.1 0.1)))", false}, | ||
{"MULTIPOLYGON EMPTY", true}, | ||
{"GEOMETRYCOLLECTION (POINT (40 10),LINESTRING (10 10, 20 20, 10 40))", false}, | ||
{"GEOMETRYCOLLECTION EMPTY", true}, | ||
{"GEOMETRYCOLLECTION (GEOMETRYCOLLECTION(POINT (40 10),LINESTRING (10 10, 20 20, 10 40)))", false}, | ||
{"GEOMETRYCOLLECTION (GEOMETRYCOLLECTION EMPTY)", true}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.wkt, func(t *testing.T) { | ||
g, err := geo.ParseGeometry(tc.wkt) | ||
require.NoError(t, err) | ||
ret, err := IsEmpty(g) | ||
require.NoError(t, err) | ||
require.Equal(t, tc.expected, ret) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.