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

exec: fix explain(vec) for queries with subqueries #40511

Merged
merged 1 commit into from
Sep 5, 2019

Conversation

jordanlewis
Copy link
Member

@jordanlewis jordanlewis commented Sep 5, 2019

Also add logic tests that show the explain(vec) plans for all of the
tpch queries.

Closes #40484.

Release note: None

@jordanlewis jordanlewis requested review from rohany and a team September 5, 2019 13:43
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@yuzefovich
Copy link
Member

Maybe we should also include postqueries in the output then?

@jordanlewis
Copy link
Member Author

Probably. We can do that later.

Copy link
Contributor

@rohany rohany left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @jordanlewis and @rohany)


pkg/sql/distsqlrun/column_exec_setup.go, line 777 at r1 (raw file):

		return planProjectionExpr(ctx, t.Operator, t.ResolvedType(), t.TypedLeft(), t.TypedRight(), columnTypes, input)
	case *tree.CastExpr:
		expr := t.Expr.(tree.TypedExpr)

was this just a style change or did this have something to do with the type related panic?


pkg/sql/exec/cast_tmpl.go, line 143 at r1 (raw file):

		sel = sel[:n]
		for _, i := range sel {
			if vecNulls.NullAt(i) {

why do you need to check that the element is actually null here?


pkg/sql/exec/cast_tmpl.go, line 146 at r1 (raw file):

				projNulls.SetNull(i)
			} else {
				panic(fmt.Errorf("Unexpected non-null at index %d", i))

this should be an execerror panic


pkg/sql/exec/cast_tmpl.go, line 154 at r1 (raw file):

				projNulls.SetNull(uint16(i))
			} else {
				panic(fmt.Errorf("Unexpected non-null at index %d", i))

ditto

Also add logic tests that show the explain(vec) plans for all of the
tpch queries.

Release note: None
Copy link
Member Author

@jordanlewis jordanlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @rohany)


pkg/sql/distsqlrun/column_exec_setup.go, line 777 at r1 (raw file):

Previously, rohany (Rohan Yadav) wrote…

was this just a style change or did this have something to do with the type related panic?

I reverted it, just a style thing.


pkg/sql/exec/cast_tmpl.go, line 143 at r1 (raw file):

Previously, rohany (Rohan Yadav) wrote…

why do you need to check that the element is actually null here?

Just a safety thing. Columns that are "unknown" type must only contain nulls. If they don't, something is very wrong.


pkg/sql/exec/cast_tmpl.go, line 146 at r1 (raw file):

Previously, rohany (Rohan Yadav) wrote…

this should be an execerror panic

Done.


pkg/sql/exec/cast_tmpl.go, line 154 at r1 (raw file):

Previously, rohany (Rohan Yadav) wrote…

ditto

Done.

Copy link
Contributor

@rohany rohany left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained

@jordanlewis
Copy link
Member Author

Thanks for the reviews!

@jordanlewis
Copy link
Member Author

bors r+

craig bot pushed a commit that referenced this pull request Sep 5, 2019
40436: sql: more test fixes for opt-driven foreign keys r=RaduBerinde a=RaduBerinde

Fixing up some expected errors in tests and making sure we don't
buffer the mutation input if we fall back to the legacy path (the
bufferNode is unnecessary and interferes with an interleaved delete
fast path).

Release note: None

40451: testcluster: don't overwrite localities indiscriminately r=andreimatei a=andreimatei

Before this patch, a TestCluster would set localities for all nodes to a
static values. This was overwriting any values set throught the
TestClusterArgs. This patch makes it so that, if any localities are set
in the args, we don't overwrite them.

Release note: None

40485: sql: Fix a bug with ordinal_position in information_schema.columns r=arulajmani a=arulajmani

When a column other than the last is dropped, ordinal_position in
information_schema.columns virtual table no longer matches attnum from
the pg_attribute table. This PR fixes this issue.

Fixes #39787

Release note (bug fix): ordinal_position in information_schema.columns
matches pg_attribute.attnum after a column is dropped.

40511: exec: fix explain(vec) for queries with subqueries r=jordanlewis a=jordanlewis

Also add logic tests that show the explain(vec) plans for all of the
tpch queries.

Closes #40484.

Release note: None

Co-authored-by: Radu Berinde <radu@cockroachlabs.com>
Co-authored-by: Andrei Matei <andrei@cockroachlabs.com>
Co-authored-by: Arul Ajmani <arula@cockroachlabs.com>
Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
@craig
Copy link
Contributor

craig bot commented Sep 5, 2019

Build failed (retrying...)

craig bot pushed a commit that referenced this pull request Sep 5, 2019
40485: sql: Fix a bug with ordinal_position in information_schema.columns r=arulajmani a=arulajmani

When a column other than the last is dropped, ordinal_position in
information_schema.columns virtual table no longer matches attnum from
the pg_attribute table. This PR fixes this issue.

Fixes #39787

Release note (bug fix): ordinal_position in information_schema.columns
matches pg_attribute.attnum after a column is dropped.

40511: exec: fix explain(vec) for queries with subqueries r=jordanlewis a=jordanlewis

Also add logic tests that show the explain(vec) plans for all of the
tpch queries.

Closes #40484.

Release note: None

40516: sql: fix table lookup for drop index  r=pbardea a=pbardea

Previously, when searching for the table relevant to a particular index
when dropping the index, we would fetch all object names and require that
all those tables exist. However, if a table was deleted in the same
transaction that table name would not be resolvable and we would error.
We already had a check to see if the table being looked up was nil, but
this check would not be used because the `required` flag was set to true.

This PR just sets the flag to false, and looks at moves on to the next
table if one of them no longer is resolvable.

Addresses #38768.

Release note (bug fix): Fix faulty error when trying to delete a table
and an unrelated index in the same transaction.

Co-authored-by: Arul Ajmani <arula@cockroachlabs.com>
Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
Co-authored-by: Paul Bardea <pbardea@gmail.com>
@craig
Copy link
Contributor

craig bot commented Sep 5, 2019

Build succeeded

@craig craig bot merged commit 3ed2af0 into cockroachdb:master Sep 5, 2019
@jordanlewis jordanlewis deleted the fix-explain-vec branch September 5, 2019 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

exec: explain(vec) crashes on query 22
4 participants