Skip to content

Commit

Permalink
sql: rename vectorize experimental_on to full
Browse files Browse the repository at this point in the history
Release justification: bug fixes and low-risk updates to new
functionality.

This commit renames `experimental_on` option of `vectorize` variable to
`full` since we're now confident in the correctness. This commit also
changes the behavior of `EXPLAIN (VEC)` slightly - previously, we were
setting `vectorize` to (what was) `experimental_on` and then running
`SupportsVectorized` check. Now we will return an error if `vectorize`
is set to `off` and in other cases we will run the check with the
current `vectorize` mode. This is done so that `EXPLAIN (VEC)` better
reflects reality.

Release note (sql change): `experimental_on` option for `vectorize`
session variable has been renamed to `full`. The only things that will
not run with `auto` but will run with `full` are unordered distinct and
two window functions (`percent_rank` and `cume_dist`), otherwise, the
two options are identical.
  • Loading branch information
yuzefovich committed Mar 14, 2020
1 parent fa79e9e commit 4f6028e
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 43 deletions.
15 changes: 14 additions & 1 deletion pkg/cmd/roachtest/tpchvec.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ func registerTPCHVec(r *testRegistry) {
19: "can cause OOM",
}

vectorizeOptionByVersionPrefix := map[string]string{
"v19.2": "experimental_on",
"v20.1": "full",
}

runTPCHVec := func(ctx context.Context, t *test, c *cluster) {
TPCHTables := []string{
"nation", "region", "part", "supplier",
Expand Down Expand Up @@ -507,7 +512,15 @@ RESTORE tpch.* FROM 'gs://cockroach-fixtures/workload/tpch/scalefactor=1/backup'
}
vectorizeSetting := "off"
if vectorize {
vectorizeSetting = "experimental_on"
for versionPrefix, vectorizeOption := range vectorizeOptionByVersionPrefix {
if strings.HasPrefix(version, versionPrefix) {
vectorizeSetting = vectorizeOption
break
}
}
if vectorizeSetting == "off" {
t.Fatal("unexpectedly didn't find the corresponding vectorize option for ON case")
}
}
cmd := fmt.Sprintf("./workload run tpch --concurrency=1 --db=tpch "+
"--max-ops=%d --queries=%d --vectorize=%s {pgurl:1-%d}",
Expand Down
8 changes: 4 additions & 4 deletions pkg/sql/colexec/execplan.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ func isSupported(
if core.Distinct.ErrorOnDup != "" {
return false, errors.Newf("distinct with error on duplicates not supported")
}
if mode != sessiondata.VectorizeExperimentalOn && mode != sessiondata.VectorizeExperimentalAlways {
if mode != sessiondata.VectorizeFull && mode != sessiondata.VectorizeExperimentalAlways {
if len(core.Distinct.OrderedColumns) < len(core.Distinct.DistinctColumns) {
return false, errors.Newf("unordered distinct can only run in 'experimental_on' vectorize mode")
return false, errors.Newf("unordered distinct can only run in 'full' vectorize mode")
}
}
return true, nil
Expand Down Expand Up @@ -273,10 +273,10 @@ func isSupported(
if _, supported := SupportedWindowFns[*wf.Func.WindowFunc]; !supported {
return false, errors.Newf("window function %s is not supported", wf.String())
}
if mode != sessiondata.VectorizeExperimentalOn && mode != sessiondata.VectorizeExperimentalAlways {
if mode != sessiondata.VectorizeFull && mode != sessiondata.VectorizeExperimentalAlways {
switch *wf.Func.WindowFunc {
case execinfrapb.WindowerSpec_PERCENT_RANK, execinfrapb.WindowerSpec_CUME_DIST:
return false, errors.Newf("window function %s can only run in 'experimental_on' vectorize mode", wf.String())
return false, errors.Newf("window function %s can only run in 'full' vectorize mode", wf.String())
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/sql/exec_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ var VectorizeClusterMode = settings.RegisterEnumSetting(
"default vectorize mode",
"auto",
map[int64]string{
int64(sessiondata.VectorizeOff): "off",
int64(sessiondata.Vectorize192Auto): "192auto",
int64(sessiondata.VectorizeAuto): "auto",
int64(sessiondata.VectorizeExperimentalOn): "experimental_on",
int64(sessiondata.VectorizeOff): "off",
int64(sessiondata.Vectorize192Auto): "192auto",
int64(sessiondata.VectorizeAuto): "auto",
int64(sessiondata.VectorizeFull): "full",
},
)

Expand Down
8 changes: 3 additions & 5 deletions pkg/sql/explain_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,9 @@ func (n *explainVecNode) startExec(params runParams) error {
flowCtx := makeFlowCtx(planCtx, plan, params)
flowCtx.Cfg.ClusterID = &distSQLPlanner.rpcCtx.ClusterID

// Temporarily set vectorize to on so that we can get the whole plan back even
// if we wouldn't support it due to lack of streaming.
origMode := flowCtx.EvalCtx.SessionData.VectorizeMode
flowCtx.EvalCtx.SessionData.VectorizeMode = sessiondata.VectorizeExperimentalOn
defer func() { flowCtx.EvalCtx.SessionData.VectorizeMode = origMode }()
if flowCtx.EvalCtx.SessionData.VectorizeMode == sessiondata.VectorizeOff {
return errors.New("vectorize set to 'off'")
}

sortedFlows := make([]flowWithNode, 0, len(flows))
for nodeID, flow := range flows {
Expand Down
8 changes: 4 additions & 4 deletions pkg/sql/logictest/logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ var logicTestConfigs = []testClusterConfig{
name: "local-vec",
numNodes: 1,
overrideAutoStats: "false",
overrideVectorize: "experimental_on",
overrideVectorize: "full",
},
{
name: "fakedist",
Expand Down Expand Up @@ -470,15 +470,15 @@ var logicTestConfigs = []testClusterConfig{
useFakeSpanResolver: true,
overrideDistSQLMode: "on",
overrideAutoStats: "false",
overrideVectorize: "experimental_on",
overrideVectorize: "full",
},
{
name: "fakedist-vec-disk",
numNodes: 3,
useFakeSpanResolver: true,
overrideDistSQLMode: "on",
overrideAutoStats: "false",
overrideVectorize: "experimental_on",
overrideVectorize: "full",
sqlExecUseDisk: true,
skipShort: true,
},
Expand Down Expand Up @@ -516,7 +516,7 @@ var logicTestConfigs = []testClusterConfig{
name: "5node-dist-vec",
numNodes: 5,
overrideDistSQLMode: "on",
overrideVectorize: "experimental_on",
overrideVectorize: "full",
overrideAutoStats: "false",
},
{
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/logictest/testdata/logic_test/set
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ statement ok
SET vectorize = auto

statement ok
SET vectorize = experimental_on
SET vectorize = full

statement ok
SET vectorize = experimental_always
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/logictest/testdata/logic_test/vectorize_local
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ INSERT INTO d VALUES (1, 1), (1, 2)

# Test that vectorized stats are collected correctly.
statement ok
SET vectorize = experimental_on
SET vectorize = full

statement ok
SET distsql = on
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/rowexec/processors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ func TestDrainingProcessorSwallowsUncertaintyError(t *testing.T) {
t.Fatal(err)
}
if vectorize {
if _, err := conn.Exec("set vectorize='experimental_on'"); err != nil {
if _, err := conn.Exec("set vectorize='full'"); err != nil {
t.Fatal(err)
}
}
Expand Down
22 changes: 11 additions & 11 deletions pkg/sql/sessiondata/session_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,14 @@ const (
// VectorizeOff means that columnar execution is disabled.
VectorizeOff VectorizeExecMode = iota
// Vectorize192Auto means that that any supported queries that use only
// streaming operators (i.e. those that do not require any buffering) will be
// run using the columnar execution.
// TODO(asubiotto): This was the auto setting for 19.2 and is kept around as
// an escape hatch. Remove in 20.2.
// streaming operators (i.e. those that do not require any buffering) will
// be run using the columnar execution.
// TODO(asubiotto): This was the auto setting for 19.2 and is kept around
// as an escape hatch. Remove in 20.2.
Vectorize192Auto
// VectorizeExperimentalOn means that any supported queries will be run using
// the columnar execution on.
VectorizeExperimentalOn
// VectorizeFull means that any supported queries will be run using the
// columnar execution on.
VectorizeFull
// VectorizeExperimentalAlways means that we attempt to vectorize all
// queries; unsupported queries will fail. Mostly used for testing.
VectorizeExperimentalAlways
Expand All @@ -291,8 +291,8 @@ func (m VectorizeExecMode) String() string {
return "192auto"
case VectorizeAuto:
return "auto"
case VectorizeExperimentalOn:
return "experimental_on"
case VectorizeFull:
return "full"
case VectorizeExperimentalAlways:
return "experimental_always"
default:
Expand All @@ -311,8 +311,8 @@ func VectorizeExecModeFromString(val string) (VectorizeExecMode, bool) {
m = Vectorize192Auto
case "AUTO":
m = VectorizeAuto
case "EXPERIMENTAL_ON":
m = VectorizeExperimentalOn
case "FULL":
m = VectorizeFull
case "EXPERIMENTAL_ALWAYS":
m = VectorizeExperimentalAlways
default:
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func TestTrace(t *testing.T) {
if _, err := sqlDB.Exec("SET distsql = off"); err != nil {
t.Fatal(err)
}
if _, err := sqlDB.Exec("SET vectorize = experimental_on"); err != nil {
if _, err := sqlDB.Exec("SET vectorize = full"); err != nil {
t.Fatal(err)
}
if _, err := sqlDB.Exec("SET tracing = on; SELECT * FROM test.foo; SET tracing = off"); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ var varGen = map[string]sessionVar{
mode, ok := sessiondata.VectorizeExecModeFromString(s)
if !ok {
return newVarValueError(`vectorize`, s,
"off", "auto", "experimental_on", "experimental_always")
"off", "auto", "full", "experimental_always")
}
m.SetVectorize(mode)
return nil
Expand Down
29 changes: 20 additions & 9 deletions pkg/workload/querybench/query_bench.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,21 @@ var queryBenchMeta = workload.Meta{
},
}

// vectorizeSetting19_1Translation is a mapping from the 19.2+ vectorize session
// vectorizeSetting19_1Translation is a mapping from the 20.1+ vectorize session
// variable value to the 19.1 syntax.
var vectorizeSetting19_1Translation = map[string]string{
"experimental_on": "on",
"full": "on",
"experimental_always": "always",
// Translate auto as on, this was not an option in 19.1.
"auto": "on",
}

// vectorizeSetting19_2Translation is a mapping from the 20.1+ vectorize session
// variable value to the 19.2 syntax.
var vectorizeSetting19_2Translation = map[string]string{
"full": "experimental_on",
}

// Meta implements the Generator interface.
func (*queryBench) Meta() workload.Meta { return queryBenchMeta }

Expand Down Expand Up @@ -125,14 +131,19 @@ func (g *queryBench) Ops(urls []string, reg *histogram.Registry) (workload.Query
if g.vectorize != "" {
_, err := db.Exec("SET vectorize=" + g.vectorize)
if err != nil && strings.Contains(err.Error(), "unrecognized configuration") {
if _, ok := vectorizeSetting19_1Translation[g.vectorize]; !ok {
// Unrecognized setting value.
return workload.QueryLoad{}, err
if _, ok := vectorizeSetting19_2Translation[g.vectorize]; ok {
// Fall back to using the pre-20.1 vectorize options.
_, err = db.Exec("SET vectorize=" + vectorizeSetting19_2Translation[g.vectorize])
} else {
if _, ok := vectorizeSetting19_1Translation[g.vectorize]; !ok {
// Unrecognized setting value.
return workload.QueryLoad{}, err
}
// Fall back to using the pre-19.2 syntax.
// TODO(asubiotto): Remove this once we stop running this test
// against 19.1.
_, err = db.Exec("SET experimental_vectorize=" + vectorizeSetting19_1Translation[g.vectorize])
}
// Fall back to using the pre-19.2 syntax.
// TODO(asubiotto): Remove this once we stop running this test against
// 19.1.
_, err = db.Exec("SET experimental_vectorize=" + vectorizeSetting19_1Translation[g.vectorize])
}
if err != nil {
return workload.QueryLoad{}, err
Expand Down

0 comments on commit 4f6028e

Please sign in to comment.