Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
84360: sql/sem/builtins: move definitions map to new package r=Xiang-Gu a=ajwerner

Previously, the definition of builtin functions live in the `builtins`
package. This was undesirable because various other packages need to
acceess builtins properties by name, but it has a been a headache to
achieve this without importing the `builtins` package, which stands
pretty high in the dependecy chain (e.g. `seqexpr`, `memo`).

This PR moves builtins definition into a new registry package that the
`builtins` package calls to register builtin functions, which happens
in the `init()` function. This way, other lower level packages, who
wish to access builtins properties, need only to import the newly
created `builtinsregistry` package.

Release note: None

84376: opt: add assertion that selectivity is never NaN r=rytaft a=rytaft

This commit addresses a leftover comment from cockroachdb#84366.

Release note: None

84392: roachtest: wait for a 5x replication instead of 3x r=lidorcarmel a=lidorcarmel

Flaky test: we wait for a 3x replication and then drain 3 nodes. Then we
sometimes have ranges with all 3 replicas on those 3 nodes, stuck forever.

Instead the test should wait for a 5x replication before starting the drain.

Fixes cockroachdb#84128.

Release note: None

Co-authored-by: Andrew Werner <[email protected]>
Co-authored-by: Rebecca Taft <[email protected]>
Co-authored-by: Lidor Carmel <[email protected]>
  • Loading branch information
4 people committed Jul 13, 2022
4 parents 6e985b9 + cee2f34 + 177816c + 2b62631 commit 37df70d
Show file tree
Hide file tree
Showing 61 changed files with 247 additions and 187 deletions.
1 change: 1 addition & 0 deletions pkg/cmd/docgen/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ go_library(
"//pkg/cli/exit",
"//pkg/cmd/docgen/extract",
"//pkg/sql/sem/builtins",
"//pkg/sql/sem/builtins/builtinsregistry",
"//pkg/sql/sem/tree",
"//pkg/util/envutil",
"//pkg/util/log",
Expand Down
3 changes: 2 additions & 1 deletion pkg/cmd/docgen/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"strings"

"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins/builtinsregistry"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/errors"
"github.com/golang-commonmark/markdown"
Expand Down Expand Up @@ -181,7 +182,7 @@ func generateFunctions(from []string, categorize bool) []byte {
continue
}
seen[name] = struct{}{}
props, fns := builtins.GetBuiltinProperties(name)
props, fns := builtinsregistry.GetBuiltinProperties(name)
if !props.ShouldDocument() {
continue
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/roachtest/tests/decommission.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func runDrainAndDecommission(
run(`SET CLUSTER SETTING kv.snapshot_recovery.max_rate='2GiB'`)

// Wait for initial up-replication.
err := WaitFor3XReplication(ctx, t, db)
err := WaitForReplication(ctx, t, db, defaultReplicationFactor)
require.NoError(t, err)
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/sql/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ go_library(
"//pkg/sql/sem/asof",
"//pkg/sql/sem/builtins",
"//pkg/sql/sem/builtins/builtinconstants",
"//pkg/sql/sem/builtins/builtinsregistry",
"//pkg/sql/sem/cast",
"//pkg/sql/sem/catconstants",
"//pkg/sql/sem/catid",
Expand Down Expand Up @@ -690,6 +691,7 @@ go_test(
"//pkg/sql/scrub",
"//pkg/sql/scrub/scrubtestutils",
"//pkg/sql/sem/builtins",
"//pkg/sql/sem/builtins/builtinsregistry",
"//pkg/sql/sem/catconstants",
"//pkg/sql/sem/catid",
"//pkg/sql/sem/eval",
Expand Down
3 changes: 2 additions & 1 deletion pkg/sql/builtin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

"github.com/cockroachdb/cockroach/pkg/base"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins/builtinsregistry"
"github.com/cockroachdb/cockroach/pkg/sql/types"
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
Expand Down Expand Up @@ -46,7 +47,7 @@ func TestFuncNull(t *testing.T) {
case "crdb_internal.force_panic", "crdb_internal.force_log_fatal", "pg_sleep":
continue
}
_, variations := builtins.GetBuiltinProperties(name)
_, variations := builtinsregistry.GetBuiltinProperties(name)
for _, builtin := range variations {
// Untyped NULL.
{
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/catalog/seqexpr/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ go_test(
":seqexpr",
"//pkg/sql/parser",
"//pkg/sql/sem/builtins",
"//pkg/sql/sem/builtins/builtinsregistry",
"//pkg/sql/sem/tree",
"//pkg/sql/types",
],
Expand Down
9 changes: 5 additions & 4 deletions pkg/sql/catalog/seqexpr/sequence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import (

"github.com/cockroachdb/cockroach/pkg/sql/catalog/seqexpr"
"github.com/cockroachdb/cockroach/pkg/sql/parser"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins"
_ "github.com/cockroachdb/cockroach/pkg/sql/sem/builtins" // register all builtins in builtins:init() for seqexpr package
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins/builtinsregistry"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/types"
)
Expand Down Expand Up @@ -50,7 +51,7 @@ func TestGetSequenceFromFunc(t *testing.T) {
if !ok {
t.Fatal("Expr is not a FuncExpr")
}
identifier, err := seqexpr.GetSequenceFromFunc(funcExpr, builtins.GetBuiltinProperties)
identifier, err := seqexpr.GetSequenceFromFunc(funcExpr, builtinsregistry.GetBuiltinProperties)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -96,7 +97,7 @@ func TestGetUsedSequences(t *testing.T) {
if err != nil {
t.Fatal(err)
}
identifiers, err := seqexpr.GetUsedSequences(typedExpr, builtins.GetBuiltinProperties)
identifiers, err := seqexpr.GetUsedSequences(typedExpr, builtinsregistry.GetBuiltinProperties)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -147,7 +148,7 @@ func TestReplaceSequenceNamesWithIDs(t *testing.T) {
if err != nil {
t.Fatal(err)
}
newExpr, err := seqexpr.ReplaceSequenceNamesWithIDs(typedExpr, namesToID, builtins.GetBuiltinProperties)
newExpr, err := seqexpr.ReplaceSequenceNamesWithIDs(typedExpr, namesToID, builtinsregistry.GetBuiltinProperties)
if err != nil {
t.Fatal(err)
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/sql/crdb_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/rowenc"
"github.com/cockroachdb/cockroach/pkg/sql/rowinfra"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins/builtinsregistry"
"github.com/cockroachdb/cockroach/pkg/sql/sem/catconstants"
"github.com/cockroachdb/cockroach/pkg/sql/sem/eval"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
Expand Down Expand Up @@ -2412,7 +2413,7 @@ CREATE TABLE crdb_internal.builtin_functions (
)`,
populate: func(ctx context.Context, _ *planner, _ catalog.DatabaseDescriptor, addRow func(...tree.Datum) error) error {
for _, name := range builtins.AllBuiltinNames {
props, overloads := builtins.GetBuiltinProperties(name)
props, overloads := builtinsregistry.GetBuiltinProperties(name)
for _, f := range overloads {
if err := addRow(
tree.NewDString(name),
Expand Down
6 changes: 3 additions & 3 deletions pkg/sql/create_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror"
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgnotice"
"github.com/cockroachdb/cockroach/pkg/sql/privilege"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins/builtinsregistry"
"github.com/cockroachdb/cockroach/pkg/sql/sem/eval"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/sqlerrors"
Expand Down Expand Up @@ -435,7 +435,7 @@ func replaceSeqNamesWithIDs(
ctx context.Context, sc resolver.SchemaResolver, viewQuery string,
) (string, error) {
replaceSeqFunc := func(expr tree.Expr) (recurse bool, newExpr tree.Expr, err error) {
seqIdentifiers, err := seqexpr.GetUsedSequences(expr, builtins.GetBuiltinProperties)
seqIdentifiers, err := seqexpr.GetUsedSequences(expr, builtinsregistry.GetBuiltinProperties)
if err != nil {
return false, expr, err
}
Expand All @@ -447,7 +447,7 @@ func replaceSeqNamesWithIDs(
}
seqNameToID[seqIdentifier.SeqName] = int64(seqDesc.ID)
}
newExpr, err = seqexpr.ReplaceSequenceNamesWithIDs(expr, seqNameToID, builtins.GetBuiltinProperties)
newExpr, err = seqexpr.ReplaceSequenceNamesWithIDs(expr, seqNameToID, builtinsregistry.GetBuiltinProperties)
if err != nil {
return false, expr, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/distsql/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ go_test(
"//pkg/sql/randgen",
"//pkg/sql/rowenc",
"//pkg/sql/rowexec",
"//pkg/sql/sem/builtins",
"//pkg/sql/sem/builtins/builtinsregistry",
"//pkg/sql/sem/eval",
"//pkg/sql/sem/tree",
"//pkg/sql/types",
Expand Down
4 changes: 2 additions & 2 deletions pkg/sql/distsql/columnar_operators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/execinfrapb"
"github.com/cockroachdb/cockroach/pkg/sql/randgen"
"github.com/cockroachdb/cockroach/pkg/sql/rowenc"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins/builtinsregistry"
"github.com/cockroachdb/cockroach/pkg/sql/sem/eval"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/types"
Expand Down Expand Up @@ -121,7 +121,7 @@ func TestAggregateFuncToNumArguments(t *testing.T) {
check := func(t *testing.T, fn execinfrapb.AggregatorSpec_Func) {
n, ok := aggregateFuncToNumArguments[fn]
require.Truef(t, ok, "didn't find number of arguments for %s", fn)
_, overloads := builtins.GetBuiltinProperties(strings.ToLower(fn.String()))
_, overloads := builtinsregistry.GetBuiltinProperties(strings.ToLower(fn.String()))
checkForOverload(t, n, overloads)
}

Expand Down
1 change: 1 addition & 0 deletions pkg/sql/execinfra/execagg/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ go_library(
deps = [
"//pkg/sql/execinfrapb",
"//pkg/sql/sem/builtins",
"//pkg/sql/sem/builtins/builtinsregistry",
"//pkg/sql/sem/eval",
"//pkg/sql/sem/tree",
"//pkg/sql/types",
Expand Down
5 changes: 3 additions & 2 deletions pkg/sql/execinfra/execagg/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

"github.com/cockroachdb/cockroach/pkg/sql/execinfrapb"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins/builtinsregistry"
"github.com/cockroachdb/cockroach/pkg/sql/sem/eval"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/types"
Expand All @@ -38,7 +39,7 @@ func GetAggregateInfo(
return builtins.NewAnyNotNullAggregate, inputTypes[0], nil
}

_, builtins := builtins.GetBuiltinProperties(strings.ToLower(fn.String()))
_, builtins := builtinsregistry.GetBuiltinProperties(strings.ToLower(fn.String()))
for _, b := range builtins {
typs := b.Types.Types()
if len(typs) != len(inputTypes) {
Expand Down Expand Up @@ -131,7 +132,7 @@ func GetWindowFunctionInfo(
"function is neither an aggregate nor a window function",
)
}
_, builtins := builtins.GetBuiltinProperties(strings.ToLower(funcStr))
_, builtins := builtinsregistry.GetBuiltinProperties(strings.ToLower(funcStr))
for _, b := range builtins {
typs := b.Types.Types()
if len(typs) != len(inputTypes) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/opt/exec/execbuilder/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ go_library(
"//pkg/sql/pgwire/pgcode",
"//pkg/sql/pgwire/pgerror",
"//pkg/sql/row",
"//pkg/sql/sem/builtins",
"//pkg/sql/sem/builtins/builtinsregistry",
"//pkg/sql/sem/eval",
"//pkg/sql/sem/tree",
"//pkg/sql/sem/tree/treebin",
Expand Down
4 changes: 2 additions & 2 deletions pkg/sql/opt/exec/execbuilder/relational.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/opt/xform"
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode"
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins/builtinsregistry"
"github.com/cockroachdb/cockroach/pkg/sql/sem/eval"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree/treewindow"
Expand Down Expand Up @@ -2404,7 +2404,7 @@ func (b *Builder) buildWindow(w *memo.WindowExpr) (execPlan, error) {
if !b.disableTelemetry {
telemetry.Inc(sqltelemetry.WindowFunctionCounter(name))
}
props, _ := builtins.GetBuiltinProperties(name)
props, _ := builtinsregistry.GetBuiltinProperties(name)

args := make([]tree.TypedExpr, fn.ChildCount())
argIdxs[i] = make([]exec.NodeColumnOrdinal, fn.ChildCount())
Expand Down
4 changes: 2 additions & 2 deletions pkg/sql/opt/exec/execbuilder/scalar.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/opt"
"github.com/cockroachdb/cockroach/pkg/sql/opt/exec"
"github.com/cockroachdb/cockroach/pkg/sql/opt/memo"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins/builtinsregistry"
"github.com/cockroachdb/cockroach/pkg/sql/sem/eval"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree/treebin"
Expand Down Expand Up @@ -362,7 +362,7 @@ func (b *Builder) buildAssignmentCast(
}
const fnName = "crdb_internal.assignment_cast"
funcRef := b.wrapFunction(fnName)
props, overloads := builtins.GetBuiltinProperties(fnName)
props, overloads := builtinsregistry.GetBuiltinProperties(fnName)
return tree.NewTypedFuncExpr(
funcRef,
0, /* aggQualifier */
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/opt/memo/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ go_test(
"//pkg/sql/parser",
"//pkg/sql/randgen",
"//pkg/sql/sem/builtins",
"//pkg/sql/sem/builtins/builtinsregistry",
"//pkg/sql/sem/eval",
"//pkg/sql/sem/tree",
"//pkg/sql/sem/tree/treewindow",
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/opt/memo/typing.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func BinaryAllowsNullArgs(op opt.Operator, leftType, rightType *types.T) bool {
return o.NullableArgs
}

// GetBuiltinProperties is set to builtins.GetBuiltinProperties in an init
// GetBuiltinProperties is set to builtinsregistry.GetBuiltinProperties in an init
// function in the norm package. This allows the memo package to resolve builtin
// functions without importing the builtins package.
var GetBuiltinProperties func(name string) (*tree.FunctionProperties, []tree.Overload)
Expand Down
3 changes: 2 additions & 1 deletion pkg/sql/opt/memo/typing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/opt"
"github.com/cockroachdb/cockroach/pkg/sql/opt/memo"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins/builtinsregistry"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/types"
tu "github.com/cockroachdb/cockroach/pkg/testutils"
Expand Down Expand Up @@ -137,7 +138,7 @@ func TestTypingAggregateAssumptions(t *testing.T) {
// These are treated as special cases.
continue
}
_, overloads := builtins.GetBuiltinProperties(name)
_, overloads := builtinsregistry.GetBuiltinProperties(name)
for i, overload := range overloads {
// Check for basic ambiguity where two different aggregate function
// overloads both allow equivalent operand types.
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/opt/norm/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ go_library(
"//pkg/sql/privilege",
"//pkg/sql/rowenc/keyside",
"//pkg/sql/sem/builtins",
"//pkg/sql/sem/builtins/builtinsregistry",
"//pkg/sql/sem/cast",
"//pkg/sql/sem/eval",
"//pkg/sql/sem/tree",
Expand Down
4 changes: 2 additions & 2 deletions pkg/sql/opt/norm/comp_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ package norm
import (
"github.com/cockroachdb/cockroach/pkg/sql/opt"
"github.com/cockroachdb/cockroach/pkg/sql/opt/memo"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins/builtinsregistry"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/types"
"github.com/cockroachdb/errors"
Expand Down Expand Up @@ -104,7 +104,7 @@ func (c *CustomFuncs) MakeTimeZoneFunction(zone opt.ScalarExpr, ts opt.ScalarExp
// timezone() function with a second argument that matches the given input type.
// If no overload is found, findTimeZoneFunction panics.
func findTimeZoneFunction(typ *types.T) (*tree.FunctionProperties, *tree.Overload) {
props, overloads := builtins.GetBuiltinProperties("timezone")
props, overloads := builtinsregistry.GetBuiltinProperties("timezone")
for o := range overloads {
overload := &overloads[o]
if overload.Types.MatchAt(typ, 1) {
Expand Down
5 changes: 3 additions & 2 deletions pkg/sql/opt/norm/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/opt/cat"
"github.com/cockroachdb/cockroach/pkg/sql/opt/memo"
"github.com/cockroachdb/cockroach/pkg/sql/opt/props/physical"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins"
_ "github.com/cockroachdb/cockroach/pkg/sql/sem/builtins" // register all builtins in builtins:init() for memo package
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins/builtinsregistry"
"github.com/cockroachdb/cockroach/pkg/sql/sem/eval"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/types"
Expand Down Expand Up @@ -109,7 +110,7 @@ const maxConstructorStackDepth = 10_000
// Injecting this builtins dependency in the init function allows the memo
// package to access builtin properties without importing the builtins package.
func init() {
memo.GetBuiltinProperties = builtins.GetBuiltinProperties
memo.GetBuiltinProperties = builtinsregistry.GetBuiltinProperties
}

// Init initializes a Factory structure with a new, blank memo structure inside.
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/opt/optbuilder/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ go_library(
"//pkg/sql/pgwire/pgerror",
"//pkg/sql/privilege",
"//pkg/sql/sem/asof",
"//pkg/sql/sem/builtins",
"//pkg/sql/sem/builtins/builtinsregistry",
"//pkg/sql/sem/cast",
"//pkg/sql/sem/catconstants",
"//pkg/sql/sem/eval",
Expand Down
4 changes: 2 additions & 2 deletions pkg/sql/opt/optbuilder/create_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ package optbuilder
import (
"github.com/cockroachdb/cockroach/pkg/sql/opt/memo"
"github.com/cockroachdb/cockroach/pkg/sql/opt/props/physical"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins/builtinsregistry"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/sqlerrors"
"github.com/cockroachdb/cockroach/pkg/sql/types"
Expand Down Expand Up @@ -81,7 +81,7 @@ func (b *Builder) buildCreateTable(ct *tree.CreateTable, inScope *scope) (outSco
input = outScope.expr
if !ct.AsHasUserSpecifiedPrimaryKey() {
// Synthesize rowid column, and append to end of column list.
props, overloads := builtins.GetBuiltinProperties("unique_rowid")
props, overloads := builtinsregistry.GetBuiltinProperties("unique_rowid")
private := &memo.FunctionPrivate{
Name: "unique_rowid",
Typ: types.Int,
Expand Down
4 changes: 2 additions & 2 deletions pkg/sql/opt/optbuilder/scalar.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode"
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror"
"github.com/cockroachdb/cockroach/pkg/sql/privilege"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins/builtinsregistry"
"github.com/cockroachdb/cockroach/pkg/sql/sem/eval"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree/treebin"
Expand Down Expand Up @@ -556,7 +556,7 @@ func (b *Builder) buildFunction(

// Add a dependency on sequences that are used as a string argument.
if b.trackViewDeps {
seqIdentifier, err := seqexpr.GetSequenceFromFunc(f, builtins.GetBuiltinProperties)
seqIdentifier, err := seqexpr.GetSequenceFromFunc(f, builtinsregistry.GetBuiltinProperties)
if err != nil {
panic(err)
}
Expand Down
Loading

0 comments on commit 37df70d

Please sign in to comment.