diff --git a/pkg/cmd/roachtest/tpchvec.go b/pkg/cmd/roachtest/tpchvec.go index ef9f85fc37ee..ffbb1f41f49d 100644 --- a/pkg/cmd/roachtest/tpchvec.go +++ b/pkg/cmd/roachtest/tpchvec.go @@ -45,6 +45,10 @@ func registerTPCHVec(r *testRegistry) { 9: "can cause OOM", 19: "can cause OOM", } + vectorizeOptionByVersionPrefix := map[string]string{ + "v19.2": "experimental_on", + "v20.1": "on", + } TPCHTables := []string{ "nation", "region", "part", "supplier", @@ -554,7 +558,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}", diff --git a/pkg/sql/colexec/execplan.go b/pkg/sql/colexec/execplan.go index 1899ec34a0f3..f9f7d9f4eea3 100644 --- a/pkg/sql/colexec/execplan.go +++ b/pkg/sql/colexec/execplan.go @@ -23,6 +23,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/execinfra" "github.com/cockroachdb/cockroach/pkg/sql/execinfrapb" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" + "github.com/cockroachdb/cockroach/pkg/sql/sessiondata" "github.com/cockroachdb/cockroach/pkg/sql/sqlbase" "github.com/cockroachdb/cockroach/pkg/sql/types" "github.com/cockroachdb/cockroach/pkg/util" @@ -139,10 +140,14 @@ type NewColOperatorResult struct { MetadataSources []execinfrapb.MetadataSource IsStreaming bool // CanRunInAutoMode returns whether the result can be run in auto mode if - // IsStreaming is false. This applies to operators that can spill to disk, but - // also operators such as the hash aggregator that buffer, but not - // proportionally to the input size (in the hash aggregator's case, it is the - // number of distinct groups). + // IsStreaming is false. This applies to operators that can spill to disk, + // but also operators such as the hash aggregator that buffer, but not + // proportionally to the input size (in the hash aggregator's case, it is + // the number of distinct groups). + // NOTE: if you set this value to 'false' for some operator, make sure to + // make the corresponding adjustment to 'isSupported' check so that we can + // plan wrapped processor core in the vectorized flow rather than rejecting + // the vectorization entirely in 'auto' mode. CanRunInAutoMode bool BufferingOpMemMonitors []*mon.BytesMonitor BufferingOpMemAccounts []*mon.BoundAccount @@ -185,8 +190,12 @@ const noFilterIdx = -1 // isSupported checks whether we have a columnar operator equivalent to a // processor described by spec. Note that it doesn't perform any other checks // (like validity of the number of inputs). -func isSupported(spec *execinfrapb.ProcessorSpec) (bool, error) { +func isSupported( + mode sessiondata.VectorizeExecMode, spec *execinfrapb.ProcessorSpec, +) (bool, error) { core := spec.Core + isFullVectorization := mode == sessiondata.VectorizeOn || + mode == sessiondata.VectorizeExperimentalAlways switch { case core.Noop != nil: @@ -227,6 +236,11 @@ func isSupported(spec *execinfrapb.ProcessorSpec) (bool, error) { if core.Distinct.ErrorOnDup != "" { return false, errors.Newf("distinct with error on duplicates not supported") } + if !isFullVectorization { + if len(core.Distinct.OrderedColumns) < len(core.Distinct.DistinctColumns) { + return false, errors.Newf("unordered distinct can only run in vectorize 'on' mode") + } + } return true, nil case core.Ordinality != nil: @@ -269,6 +283,12 @@ func isSupported(spec *execinfrapb.ProcessorSpec) (bool, error) { if _, supported := SupportedWindowFns[*wf.Func.WindowFunc]; !supported { return false, errors.Newf("window function %s is not supported", wf.String()) } + if !isFullVectorization { + switch *wf.Func.WindowFunc { + case execinfrapb.WindowerSpec_PERCENT_RANK, execinfrapb.WindowerSpec_CUME_DIST: + return false, errors.Newf("window function %s can only run in vectorize 'on' mode", wf.String()) + } + } } return true, nil @@ -519,7 +539,7 @@ func NewColOperator( // before any specs are planned. Used if there is a need to backtrack. resultPreSpecPlanningStateShallowCopy := result - supported, err := isSupported(spec) + supported, err := isSupported(flowCtx.EvalCtx.SessionData.VectorizeMode, spec) if !supported { // We refuse to wrap LocalPlanNode processor (which is a DistSQL wrapper // around a planNode) because it creates complications, and a flow with diff --git a/pkg/sql/colexec/window_functions_test.go b/pkg/sql/colexec/window_functions_test.go index 9cba30c4ee9d..49f1f2dca646 100644 --- a/pkg/sql/colexec/window_functions_test.go +++ b/pkg/sql/colexec/window_functions_test.go @@ -19,6 +19,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/execinfra" "github.com/cockroachdb/cockroach/pkg/sql/execinfrapb" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" + "github.com/cockroachdb/cockroach/pkg/sql/sessiondata" "github.com/cockroachdb/cockroach/pkg/sql/types" "github.com/cockroachdb/cockroach/pkg/testutils/colcontainerutils" "github.com/cockroachdb/cockroach/pkg/util/leaktest" @@ -45,6 +46,7 @@ func TestWindowFunctions(t *testing.T) { st := cluster.MakeTestingClusterSettings() evalCtx := tree.MakeTestingEvalContext(st) defer evalCtx.Stop(ctx) + evalCtx.SessionData.VectorizeMode = sessiondata.VectorizeOn flowCtx := &execinfra.FlowCtx{ EvalCtx: &evalCtx, Cfg: &execinfra.ServerConfig{ diff --git a/pkg/sql/distsql/server.go b/pkg/sql/distsql/server.go index c4763d91b338..bd4d8de64c74 100644 --- a/pkg/sql/distsql/server.go +++ b/pkg/sql/distsql/server.go @@ -278,6 +278,7 @@ func (ds *ServerImpl) setupFlow( BytesEncodeFormat: be, ExtraFloatDigits: int(req.EvalContext.ExtraFloatDigits), }, + VectorizeMode: sessiondata.VectorizeExecMode(req.EvalContext.Vectorize), } ie := &lazyInternalExecutor{ newInternalExecutor: func() sqlutil.InternalExecutor { diff --git a/pkg/sql/exec_util.go b/pkg/sql/exec_util.go index 172d56f5faa0..231929c27813 100644 --- a/pkg/sql/exec_util.go +++ b/pkg/sql/exec_util.go @@ -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.VectorizeOn): "on", }, ) diff --git a/pkg/sql/explain_plan.go b/pkg/sql/explain_plan.go index 0d3015031f4c..2fe46e8bd7f3 100644 --- a/pkg/sql/explain_plan.go +++ b/pkg/sql/explain_plan.go @@ -243,6 +243,9 @@ func populateExplain( } _, err := colflow.SupportsVectorized(params.ctx, flowCtx, flow.Processors, fuseOpt, nil /* output */) isVec = isVec && (err == nil) + if !isVec { + break + } } } } diff --git a/pkg/sql/explain_vec.go b/pkg/sql/explain_vec.go index 6a9614fcd464..c9c6420ccfef 100644 --- a/pkg/sql/explain_vec.go +++ b/pkg/sql/explain_vec.go @@ -75,11 +75,15 @@ 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 }() + // We want to get the vectorized plan which would be executed with the + // current 'vectorize' option. If 'vectorize' is set to 'off', then the + // vectorized engine is disabled, and we will return an error in such case. + // With all other options, we don't change the setting to the + // most-inclusive option as we used to because the plan can be different + // based on 'vectorize' setting. + if flowCtx.EvalCtx.SessionData.VectorizeMode == sessiondata.VectorizeOff { + return errors.New("vectorize is set to 'off'") + } sortedFlows := make([]flowWithNode, 0, len(flows)) for nodeID, flow := range flows { diff --git a/pkg/sql/logictest/logic.go b/pkg/sql/logictest/logic.go index 06cbcb070379..e1a86c491e60 100644 --- a/pkg/sql/logictest/logic.go +++ b/pkg/sql/logictest/logic.go @@ -446,7 +446,7 @@ var logicTestConfigs = []testClusterConfig{ name: "local-vec", numNodes: 1, overrideAutoStats: "false", - overrideVectorize: "experimental_on", + overrideVectorize: "on", }, { name: "fakedist", @@ -478,7 +478,7 @@ var logicTestConfigs = []testClusterConfig{ useFakeSpanResolver: true, overrideDistSQLMode: "on", overrideAutoStats: "false", - overrideVectorize: "experimental_on", + overrideVectorize: "on", }, { name: "fakedist-vec-disk", @@ -486,7 +486,7 @@ var logicTestConfigs = []testClusterConfig{ useFakeSpanResolver: true, overrideDistSQLMode: "on", overrideAutoStats: "false", - overrideVectorize: "experimental_on", + overrideVectorize: "on", sqlExecUseDisk: true, skipShort: true, }, @@ -524,7 +524,7 @@ var logicTestConfigs = []testClusterConfig{ name: "5node-dist-vec", numNodes: 5, overrideDistSQLMode: "on", - overrideVectorize: "experimental_on", + overrideVectorize: "on", overrideAutoStats: "false", }, { diff --git a/pkg/sql/logictest/testdata/logic_test/explain_analyze_plans b/pkg/sql/logictest/testdata/logic_test/explain_analyze_plans index 9230010d2669..3e87c2183e5d 100644 --- a/pkg/sql/logictest/testdata/logic_test/explain_analyze_plans +++ b/pkg/sql/logictest/testdata/logic_test/explain_analyze_plans @@ -66,7 +66,7 @@ https://cockroachdb.github.io/distsqlplan/decode.html#eJzsmW1P40YQx9_3U6z2Fegc7F query T SELECT url FROM [EXPLAIN ANALYZE (DISTSQL) SELECT DISTINCT(kw.w) FROM kv JOIN kw ON kv.k = kw.w ORDER BY kw.w] ---- -https://cockroachdb.github.io/distsqlplan/decode.html#eJzkWV9v4rgXff99Cus-tfqFSZw_FCKN1HbKapntwiz0YWdHPKTEWyIgYW1Tpqr63VcJdGlIaztNJkaat8kfx-den3PPnPII7J8F-DDuXfc-3aA1XaBfRsPf0bfen1-uL_oDdDG4uP76Vw-dXPXHN-M_rk_R7tX0uj_4dINO5psPm9Ptsvk9-jzsD9B8g4YDNL__M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csAt5792H3KlueKdCyN1O6yNeQ7GLR7xjUuLHAaEkUXMuWh9258hhd1ofdsQPu7BfvPuwI78ljLlcJbHkRRO8-mQre_M8uOdbJ8kkFTP-RSSzzTLbw9GG23wZBVyq7VW2PRjE20vZBqvDvSYwbbQ07TahmaWnaY2asXpwrwlMGy1dqFlNulCzEs2KtPUzbedgqwjbWtjRvy1HC7v6lV0tzJie7jYJlx5GwqWHsXAhNBIuRDUSrvMm4dLDSLj0MBYuhEbChahGwtXTuvRCb9KLJuGijeYHQiMeR2jM5BiOuBxTjs2QZkOk2RRpOEYazpFmg4TqJwlFRgltNEtoaZjUsruexuyup1G7Izhmd0Q5ZvfSIK1ldz2N2V1Po3ZHcMzuiHLM7qVpmrf7OWL30mCpZffSYKlldz2N2V1Po3ZHcMzuiHLM7qWhWsvuehqzu55G7Y7gmN0R5dhnQmmq5v_hpnq7s9Js0dp9-vLL_wEAAP__Fks7Cw== # This query verifies stats collection for WITH ORDINALITY and the hashJoiner. query T diff --git a/pkg/sql/logictest/testdata/logic_test/set b/pkg/sql/logictest/testdata/logic_test/set index 6011863ad875..db9d38e5ae36 100644 --- a/pkg/sql/logictest/testdata/logic_test/set +++ b/pkg/sql/logictest/testdata/logic_test/set @@ -172,7 +172,7 @@ statement ok SET vectorize = auto statement ok -SET vectorize = experimental_on +SET vectorize = on statement ok SET vectorize = experimental_always diff --git a/pkg/sql/logictest/testdata/logic_test/vectorize_local b/pkg/sql/logictest/testdata/logic_test/vectorize_local index c678862017aa..0c1eb6821da7 100644 --- a/pkg/sql/logictest/testdata/logic_test/vectorize_local +++ b/pkg/sql/logictest/testdata/logic_test/vectorize_local @@ -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 = on statement ok SET distsql = on diff --git a/pkg/sql/opt/exec/execbuilder/testdata/aggregate b/pkg/sql/opt/exec/execbuilder/testdata/aggregate index 56bc0c7fd0c4..ceec8f4dc722 100644 --- a/pkg/sql/opt/exec/execbuilder/testdata/aggregate +++ b/pkg/sql/opt/exec/execbuilder/testdata/aggregate @@ -954,7 +954,7 @@ query TTTTT EXPLAIN (TYPES) SELECT 1 a FROM kv GROUP BY v, w::DECIMAL HAVING w::DECIMAL > 1; ---- · distributed false · · -· vectorized false · · +· vectorized true · · render · · (a int) · │ render 0 (1)[int] · · └── distinct · · (column5 decimal, v int) · diff --git a/pkg/sql/opt/exec/execbuilder/testdata/dist_union b/pkg/sql/opt/exec/execbuilder/testdata/dist_union index 2d3786c1a79b..491057a1610b 100644 --- a/pkg/sql/opt/exec/execbuilder/testdata/dist_union +++ b/pkg/sql/opt/exec/execbuilder/testdata/dist_union @@ -10,7 +10,7 @@ query TTT EXPLAIN SELECT v FROM uniontest UNION SELECT k FROM uniontest ---- · distributed true -· vectorized false +· vectorized true union · · ├── scan · · │ table uniontest@primary diff --git a/pkg/sql/opt/exec/execbuilder/testdata/distinct b/pkg/sql/opt/exec/execbuilder/testdata/distinct index 36c8573f76bc..b4a639cd94ec 100644 --- a/pkg/sql/opt/exec/execbuilder/testdata/distinct +++ b/pkg/sql/opt/exec/execbuilder/testdata/distinct @@ -91,7 +91,7 @@ query TTT EXPLAIN SELECT DISTINCT y AS w FROM xyz ORDER BY y ---- · distributed false -· vectorized false +· vectorized true sort · · │ order +w └── distinct · · diff --git a/pkg/sql/opt/exec/execbuilder/testdata/distinct_on b/pkg/sql/opt/exec/execbuilder/testdata/distinct_on index 3551fb313c3c..7fe8c481e548 100644 --- a/pkg/sql/opt/exec/execbuilder/testdata/distinct_on +++ b/pkg/sql/opt/exec/execbuilder/testdata/distinct_on @@ -28,7 +28,7 @@ query TTTTT EXPLAIN (VERBOSE) SELECT DISTINCT ON (x, y, z) x, y, z FROM xyz ---- · distributed false · · -· vectorized false · · +· vectorized true · · distinct · · (x, y, z) · │ distinct on x, y, z · · └── scan · · (x, y, z) · @@ -39,7 +39,7 @@ query TTTTT EXPLAIN (VERBOSE) SELECT DISTINCT ON (z, x, y) x FROM xyz ---- · distributed false · · -· vectorized false · · +· vectorized true · · render · · (x) · │ render 0 x · · └── distinct · · (x, y, z) · @@ -90,7 +90,7 @@ query TTTTT EXPLAIN (VERBOSE) SELECT DISTINCT ON (x, y) y, x FROM xyz ---- · distributed false · · -· vectorized false · · +· vectorized true · · render · · (y, x) · │ render 0 y · · │ render 1 x · · @@ -104,7 +104,7 @@ query TTTTT EXPLAIN (VERBOSE) SELECT DISTINCT ON (y, x) x FROM xyz ---- · distributed false · · -· vectorized false · · +· vectorized true · · render · · (x) · │ render 0 x · · └── distinct · · (x, y) · @@ -117,7 +117,7 @@ query TTTTT EXPLAIN (VERBOSE) SELECT DISTINCT ON (y, x, x, y, x) x, y FROM xyz ---- · distributed false · · -· vectorized false · · +· vectorized true · · distinct · · (x, y) · │ distinct on x, y · · └── scan · · (x, y) · @@ -128,7 +128,7 @@ query TTTTT EXPLAIN (VERBOSE) SELECT DISTINCT ON(pk1, x) pk1, x FROM xyz ORDER BY pk1 ---- · distributed false · · -· vectorized false · · +· vectorized true · · render · · (pk1, x) · │ render 0 pk1 · · │ render 1 x · · @@ -143,7 +143,7 @@ query TTTTT EXPLAIN (VERBOSE) SELECT DISTINCT ON (a, c) a, b FROM abc ---- · distributed false · · -· vectorized false · · +· vectorized true · · render · · (a, b) · │ render 0 a · · │ render 1 b · · @@ -158,7 +158,7 @@ query TTTTT EXPLAIN (VERBOSE) SELECT DISTINCT ON (c, a) b, c, a FROM abc ---- · distributed false · · -· vectorized false · · +· vectorized true · · render · · (b, c, a) · │ render 0 b · · │ render 1 c · · @@ -215,7 +215,7 @@ query TTTTT EXPLAIN (VERBOSE) SELECT DISTINCT ON (x) x FROM xyz ORDER BY x DESC ---- · distributed false · · -· vectorized false · · +· vectorized true · · sort · · (x) -x │ order -x · · └── distinct · · (x) · @@ -228,7 +228,7 @@ query TTTTT EXPLAIN (VERBOSE) SELECT DISTINCT ON (x, z) y, z, x FROM xyz ORDER BY z ---- · distributed false · · -· vectorized false · · +· vectorized true · · render · · (y, z, x) · │ render 0 y · · │ render 1 z · · @@ -340,7 +340,7 @@ query TTTTT EXPLAIN (VERBOSE) SELECT DISTINCT ON(row_number() OVER()) y FROM xyz ---- · distributed false · · -· vectorized false · · +· vectorized true · · render · · (y) · │ render 0 y · · └── distinct · · (y, row_number) · @@ -360,7 +360,7 @@ query TTTTT EXPLAIN (VERBOSE) SELECT DISTINCT ON (1) x, y, z FROM xyz ---- · distributed false · · -· vectorized false · · +· vectorized true · · distinct · · (x, y, z) · │ distinct on x · · └── scan · · (x, y, z) · @@ -386,7 +386,7 @@ query TTTTT EXPLAIN (VERBOSE) SELECT DISTINCT ON(y) x AS y, y AS x FROM xyz ---- · distributed false · · -· vectorized false · · +· vectorized true · · distinct · · (y, x) · │ distinct on y · · └── scan · · (y, x) · @@ -398,7 +398,7 @@ query TTTTT EXPLAIN (VERBOSE) SELECT DISTINCT ON(x) x AS y FROM xyz ---- · distributed false · · -· vectorized false · · +· vectorized true · · distinct · · (y) · │ distinct on y · · └── scan · · (y) · @@ -413,7 +413,7 @@ query TTTTT EXPLAIN (VERBOSE) SELECT DISTINCT ON(((x)), (x, y)) x, y FROM xyz ---- · distributed false · · -· vectorized false · · +· vectorized true · · distinct · · (x, y) · │ distinct on x, y · · └── scan · · (x, y) · @@ -440,7 +440,7 @@ query TTTTT EXPLAIN (VERBOSE) SELECT DISTINCT ON (x, y, z) pk1 FROM xyz ORDER BY x ---- · distributed false · · -· vectorized false · · +· vectorized true · · render · · (pk1) · │ render 0 pk1 · · └── distinct · · (x, y, z, pk1) +x diff --git a/pkg/sql/opt/exec/execbuilder/testdata/distsql_distinct_on b/pkg/sql/opt/exec/execbuilder/testdata/distsql_distinct_on index 82849696c877..69bae239ac6f 100644 --- a/pkg/sql/opt/exec/execbuilder/testdata/distsql_distinct_on +++ b/pkg/sql/opt/exec/execbuilder/testdata/distsql_distinct_on @@ -68,7 +68,7 @@ query TTTTT EXPLAIN (VERBOSE) SELECT DISTINCT ON (x,y,z) x, y, z FROM xyz ---- · distributed true · · -· vectorized false · · +· vectorized true · · distinct · · (x, y, z) · │ distinct on x, y, z · · └── scan · · (x, y, z) · @@ -85,7 +85,7 @@ query TTTTT EXPLAIN (VERBOSE) SELECT DISTINCT ON (x,y,z) x, y, z FROM xyz ORDER BY x ---- · distributed true · · -· vectorized false · · +· vectorized true · · distinct · · (x, y, z) +x │ distinct on x, y, z · · │ order key x · · diff --git a/pkg/sql/opt/exec/execbuilder/testdata/explain b/pkg/sql/opt/exec/execbuilder/testdata/explain index 5fe1a618fe0b..ccd25216e361 100644 --- a/pkg/sql/opt/exec/execbuilder/testdata/explain +++ b/pkg/sql/opt/exec/execbuilder/testdata/explain @@ -504,7 +504,7 @@ query TTT EXPLAIN SELECT DISTINCT v FROM t ---- · distributed false -· vectorized false +· vectorized true distinct · · │ distinct on v └── scan · · @@ -515,7 +515,7 @@ query TTT SELECT tree, field, description FROM [EXPLAIN (VERBOSE) SELECT DISTINCT v FROM t LIMIT 1 OFFSET 1] ---- · distributed false -· vectorized false +· vectorized true limit · · │ offset 1 └── limit · · diff --git a/pkg/sql/opt/exec/execbuilder/testdata/lookup_join b/pkg/sql/opt/exec/execbuilder/testdata/lookup_join index e8ff2ece16c5..2fb6d7227fb2 100644 --- a/pkg/sql/opt/exec/execbuilder/testdata/lookup_join +++ b/pkg/sql/opt/exec/execbuilder/testdata/lookup_join @@ -247,7 +247,7 @@ EXPLAIN (VERBOSE) SELECT DISTINCT authors.name FROM books AS b1, books2 AS b2, a ---- tree field description columns ordering · distributed true · · -· vectorized false · · +· vectorized true · · distinct · · (name) · │ distinct on name · · └── render · · (name) · diff --git a/pkg/sql/opt/exec/execbuilder/testdata/orderby b/pkg/sql/opt/exec/execbuilder/testdata/orderby index 561e688fa788..9e6796ffd37a 100644 --- a/pkg/sql/opt/exec/execbuilder/testdata/orderby +++ b/pkg/sql/opt/exec/execbuilder/testdata/orderby @@ -48,7 +48,7 @@ query TTTTT EXPLAIN (VERBOSE) SELECT DISTINCT c, b FROM t ORDER BY b LIMIT 2 ---- · distributed false · · -· vectorized false · · +· vectorized true · · render · · (c, b) · │ render 0 c · · │ render 1 b · · diff --git a/pkg/sql/opt/exec/execbuilder/testdata/union b/pkg/sql/opt/exec/execbuilder/testdata/union index ac7dae767934..3706d14b92c9 100644 --- a/pkg/sql/opt/exec/execbuilder/testdata/union +++ b/pkg/sql/opt/exec/execbuilder/testdata/union @@ -10,7 +10,7 @@ query TTT EXPLAIN SELECT v FROM uniontest UNION SELECT k FROM uniontest ---- · distributed false -· vectorized false +· vectorized true union · · ├── scan · · │ table uniontest@primary diff --git a/pkg/sql/rowexec/processors_test.go b/pkg/sql/rowexec/processors_test.go index c56af9cea858..65ae36b4458d 100644 --- a/pkg/sql/rowexec/processors_test.go +++ b/pkg/sql/rowexec/processors_test.go @@ -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='on'"); err != nil { t.Fatal(err) } } diff --git a/pkg/sql/sessiondata/session_data.go b/pkg/sql/sessiondata/session_data.go index d8f41e058ffa..9e7ac8ea78d9 100644 --- a/pkg/sql/sessiondata/session_data.go +++ b/pkg/sql/sessiondata/session_data.go @@ -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 + // VectorizeOn means that any supported queries will be run using the + // columnar execution. + VectorizeOn // VectorizeExperimentalAlways means that we attempt to vectorize all // queries; unsupported queries will fail. Mostly used for testing. VectorizeExperimentalAlways @@ -291,8 +291,8 @@ func (m VectorizeExecMode) String() string { return "192auto" case VectorizeAuto: return "auto" - case VectorizeExperimentalOn: - return "experimental_on" + case VectorizeOn: + return "on" case VectorizeExperimentalAlways: return "experimental_always" default: @@ -311,8 +311,8 @@ func VectorizeExecModeFromString(val string) (VectorizeExecMode, bool) { m = Vectorize192Auto case "AUTO": m = VectorizeAuto - case "EXPERIMENTAL_ON": - m = VectorizeExperimentalOn + case "ON": + m = VectorizeOn case "EXPERIMENTAL_ALWAYS": m = VectorizeExperimentalAlways default: diff --git a/pkg/sql/trace_test.go b/pkg/sql/trace_test.go index 8623b236f966..297f05740beb 100644 --- a/pkg/sql/trace_test.go +++ b/pkg/sql/trace_test.go @@ -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 = on"); err != nil { t.Fatal(err) } if _, err := sqlDB.Exec("SET tracing = on; SELECT * FROM test.foo; SET tracing = off"); err != nil { diff --git a/pkg/sql/vars.go b/pkg/sql/vars.go index e2b0b4a22be8..320e8054364c 100644 --- a/pkg/sql/vars.go +++ b/pkg/sql/vars.go @@ -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", "on", "experimental_always") } m.SetVectorize(mode) return nil diff --git a/pkg/workload/querybench/query_bench.go b/pkg/workload/querybench/query_bench.go index ea28745993ef..e4b5d3ac5266 100644 --- a/pkg/workload/querybench/query_bench.go +++ b/pkg/workload/querybench/query_bench.go @@ -64,15 +64,20 @@ 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", "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{ + "on": "experimental_on", +} + // Meta implements the Generator interface. func (*queryBench) Meta() workload.Meta { return queryBenchMeta } @@ -125,14 +130,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