-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
49284: opt: synthesize check constraints on enum columns r=rohany a=rohany Fixes #49263. This PR teaches the optimizer how to synthesize check constraints on columns of an ENUM type, allowing queries like: ``` CREATE TYPE t AS ENUM ('howdy', 'hello'); CREATE TABLE tt (x t, y INT, PRIMARY KEY (x, y)); SELECT x, y FROM tt WHERE y = 2 ``` to be planned using constrained spans on the enum values, rather than a full table scan. Release note (performance improvement): Allow the optimizer to use enum information to generate better query plans. 50001: colexec: minor miscellaneous additions r=yuzefovich a=yuzefovich **colexec: add casts from datum-backed types to bools** While investigating unrelated test failures, I added this cast, so we might as well merge it. Addresses: #48135. Release note: None **colexec: add support for Values core with zero rows** Release note: None 50188: geo/geogfn: implement ST_Azimuth({geometry,geometry}) r=otan a=hueypark Fixes #48887 Release note (sql change): This PR implement adds the ST_Azimuth({geometry,geometry}) 50205: Makefile: ensure redact_safe.md generation is stable r=RichardJCai a=knz Fixes #50146 On some platforms, the default behavior of `git grep` is to number the lines (i.e. `-n` is implicitly added). This patch makes the `-n` explicit and tweaks the sed patterns to ensure that the behavior is stable. Release note: None 50239: kv/kvserver: disable the below-raft proto tracking in race builds r=petermattis a=petermattis The below-raft proto tracking is meant to catch bugs where we inadvertently starting marshaling a proto below Raft. This tracking is a source of signficant memory allocations which measurably slow down race builds. Since we're already doing this tracking in non-race builds, there is little benefit to also doing it in race builds. Disabling below-raft proto tracking for race builds reduces the time to run `testrace` on the `kv/kvserver` package from 605s to 517s on my laptop. Release note: None 50243: kv/kvserver: fix TestSideloadingSideloadedStorage w/ RocksDB r=jbowens a=jbowens Fix the TestSideloadingSideloadedStorage test when running with COCKROACH_STORAGE_ENGINE=rocksdb. The test has always depended on the exact error message surfaced from os.Remove. In #49717, diskSideloadStorage was modified to use the engine's RemoveDir operation rather than interacting with the filesystem directly. Since Pebble uses os.Remove for its implementation and emulates its error messages in its MemFS implementation, the exact message comparison continued to succeed. After #49717, when running with RocksDB, the RocksDB env's error message was surfaced, with its own context prefixing. This updates the test to case-insensitively check for 'directory not empty' instead. Fixes #50226. Release note: None Co-authored-by: Rohan Yadav <[email protected]> Co-authored-by: Yahor Yuzefovich <[email protected]> Co-authored-by: Jaewan Park <[email protected]> Co-authored-by: Raphael 'kena' Poss <[email protected]> Co-authored-by: Peter Mattis <[email protected]> Co-authored-by: Jackson Owens <[email protected]>
- Loading branch information
Showing
22 changed files
with
479 additions
and
95 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
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,58 @@ | ||
// 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 ( | ||
"math" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/geo" | ||
"github.com/cockroachdb/errors" | ||
"github.com/twpayne/go-geom" | ||
) | ||
|
||
// Azimuth returns the azimuth in radians of the segment defined by the given point geometries. | ||
// The azimuth is angle is referenced from north, and is positive clockwise. | ||
// North = 0; East = π/2; South = π; West = 3π/2. | ||
// Returns nil if the two points are the same. | ||
// Returns an error if any of the two Geometry items are not points. | ||
func Azimuth(a *geo.Geometry, b *geo.Geometry) (*float64, error) { | ||
aGeomT, err := a.AsGeomT() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
aPoint, ok := aGeomT.(*geom.Point) | ||
if !ok { | ||
return nil, errors.Newf("Argument must be POINT geometries") | ||
} | ||
|
||
bGeomT, err := b.AsGeomT() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
bPoint, ok := bGeomT.(*geom.Point) | ||
if !ok { | ||
return nil, errors.Newf("Argument must be POINT geometries") | ||
} | ||
|
||
if aPoint.X() == bPoint.X() && aPoint.Y() == bPoint.Y() { | ||
return nil, nil | ||
} | ||
|
||
atan := math.Atan2(bPoint.Y()-aPoint.Y(), bPoint.X()-aPoint.X()) // Started at East(90) counterclockwise. | ||
const degree360 = 2 * math.Pi // Added 360 degrees for always returns a positive value. | ||
const degree90 = math.Pi / 2 // Added 90 degrees to get it started at North(0). | ||
|
||
azimuth := math.Mod(degree360+degree90-atan, 2*math.Pi) | ||
|
||
return &azimuth, 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,76 @@ | ||
// 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 ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/geo" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestAzimuth(t *testing.T) { | ||
zero := 0.0 | ||
aQuarterPi := 0.7853981633974483 | ||
towQuartersPi := 1.5707963267948966 | ||
threeQuartersPi := 2.356194490192344 | ||
|
||
testCases := []struct { | ||
a string | ||
b string | ||
expected *float64 | ||
}{ | ||
{ | ||
"POINT(0 0)", | ||
"POINT(0 0)", | ||
nil, | ||
}, | ||
{ | ||
"POINT(0 0)", | ||
"POINT(1 1)", | ||
&aQuarterPi, | ||
}, | ||
{ | ||
"POINT(0 0)", | ||
"POINT(1 0)", | ||
&towQuartersPi, | ||
}, | ||
{ | ||
"POINT(0 0)", | ||
"POINT(1 -1)", | ||
&threeQuartersPi, | ||
}, | ||
{ | ||
"POINT(0 0)", | ||
"POINT(0 1)", | ||
&zero, | ||
}, | ||
} | ||
|
||
for i, tc := range testCases { | ||
t.Run(fmt.Sprintf("tc:%d", i), func(t *testing.T) { | ||
a, err := geo.ParseGeometry(tc.a) | ||
require.NoError(t, err) | ||
b, err := geo.ParseGeometry(tc.b) | ||
require.NoError(t, err) | ||
|
||
r, err := Azimuth(a, b) | ||
require.NoError(t, err) | ||
|
||
if tc.expected == nil { | ||
require.Nil(t, r) | ||
} else { | ||
require.Equal(t, *tc.expected, *r) | ||
} | ||
}) | ||
} | ||
} |
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
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
Oops, something went wrong.