Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: replace an internal error in EXPLAIN (DISTSQL) and EXPLAIN (VEC) #40803

Merged
merged 1 commit into from
Sep 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/sql/explain_distsql.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/util/hlc"
"github.com/cockroachdb/cockroach/pkg/util/tracing"
"github.com/cockroachdb/errors"
"github.com/opentracing/opentracing-go"
)

Expand Down Expand Up @@ -116,6 +117,10 @@ func (n *explainDistSQLNode) startExec(params runParams) error {

plan, err := makePhysicalPlan(planCtx, distSQLPlanner, n.plan)
if err != nil {
if len(n.subqueryPlans) > 0 {
return errors.New("running EXPLAIN (DISTSQL) on this query is " +
"unsupported because of the presence of subqueries")
}
return err
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/sql/explain_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/sessiondata"
"github.com/cockroachdb/cockroach/pkg/util/mon"
"github.com/cockroachdb/cockroach/pkg/util/treeprinter"
"github.com/cockroachdb/errors"
)

// explainVecNode is a planNode that wraps a plan and returns
Expand Down Expand Up @@ -61,6 +62,10 @@ func (n *explainVecNode) startExec(params runParams) error {
}()
plan, err := makePhysicalPlan(planCtx, distSQLPlanner, n.plan)
if err != nil {
if len(n.subqueryPlans) > 0 {
return errors.New("running EXPLAIN (VEC) on this query is " +
"unsupported because of the presence of subqueries")
}
return err
}

Expand Down
15 changes: 15 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/explain
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# LogicTest: local local-vec-off

statement ok
CREATE TABLE t (a INT PRIMARY KEY)

# Test that EXPLAIN (DISTSQL) on a query with a subquery works.
query T
SELECT url FROM [EXPLAIN (DISTSQL) SELECT * FROM (SELECT avg(a) OVER () FROM t)]
----
https://cockroachdb.github.io/distsqlplan/decode.html#eJyUkDFLBDEQhXt_xfEqhchttky1VnKNJ6doISniZjgCe0nIzKJy7H-X3RR6womW8ybf-8IcEZOnO3cghnmBhlXIJfXEnMoc1Qcb_w7TKISYR5ljq9CnQjBHSJCBYPDoXgfakfNU1g0UPIkLw1KbSzi48tEJFB6yi2xW17CTQhrlq5DF7QlGT-rv0ucQfXqjstanxpun28tOX0FhO4pZde1ZXfsf3Y44p8h0IjvX3ExWgfye6h05jaWn-5L6RVPH7cItgSeWutV12MS6mj_4Hda_wu0P2E4XnwEAAP__EY6e-w==

# Test that explaining a query that contains a subquery the result of which is
# needed to make the physical plan is rejected. See #40677.
statement error running EXPLAIN \(DISTSQL\) on this query is unsupported because of the presence of subqueries
EXPLAIN (DISTSQL) SELECT avg(a) OVER (ROWS (SELECT count(*) FROM t) PRECEDING) FROM t