Skip to content

rowexec: fix bug with distinct aggregations on JSONB columns#46711

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
rohany:json-distinct-agg
Mar 29, 2020
Merged

rowexec: fix bug with distinct aggregations on JSONB columns#46711
craig[bot] merged 1 commit intocockroachdb:masterfrom
rohany:json-distinct-agg

Conversation

@rohany
Copy link
Copy Markdown
Contributor

@rohany rohany commented Mar 28, 2020

Fixes #46709.

A recent change (#45229) was made to fix encodings to perform aggregations
on JSONB and ARRAY columns. That change missed a case in for
DISTINCT aggregations, causing a runtime error when executing
these queries.

Release justification: fixes a bug

Release note (bug fix): This PR fixes a bug with distinct aggregations
on JSONB columns.

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Member

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

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

:lgtm:

nit: in the commit message, "a case in for" sounds off.

Reviewed 2 of 2 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @jordanlewis and @rohany)


pkg/sql/rowexec/aggregator.go, line 913 at r1 (raw file):

	otherArgTypes []*types.T,
) (bool, error) {
	// Allocate one EncDatum up front.

nit: to me this comment implies that other EncDatums might be allocated, but they will not. I'd rephrase it to something like "Allocate an EncDatum that will be reused when encoding every argument".

Copy link
Copy Markdown
Member

@yuzefovich yuzefovich 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! 1 of 0 LGTMs obtained (waiting on @jordanlewis and @rohany)


pkg/sql/rowexec/aggregator.go, line 911 at r1 (raw file):

	firstArgType *types.T,
	otherArgs tree.Datums,
	otherArgTypes []*types.T,

Another nit: for some reason we seem to be using []types.T everywhere, not []*types.T although for a single we do use *types.T.

@rohany
Copy link
Copy Markdown
Contributor Author

rohany commented Mar 28, 2020

Another nit: for some reason we seem to be using []types.T everywhere, not []*types.T although for a single we do use *types.T.

Ok, I can update this. Though do I need this? The datums carry the types, I could just use that.

@rohany rohany force-pushed the json-distinct-agg branch from 34ec489 to 0d1710f Compare March 28, 2020 23:04
Fixes cockroachdb#46709.

A recent change was made to fix encodings to perform aggregations
on JSONB and ARRAY columns. That change missed a case in for
DISTINCT aggregations, causing a runtime error when executing
these queries.

Release justification: fixes a bug

Release note (bug fix): This PR fixes a bug with distinct aggregations
on JSONB columns.
@rohany rohany force-pushed the json-distinct-agg branch from 0d1710f to 5849049 Compare March 29, 2020 01:31
@rohany
Copy link
Copy Markdown
Contributor Author

rohany commented Mar 29, 2020

bors r=yuzefovich

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Mar 29, 2020

Build succeeded

@craig craig bot merged commit 92495ff into cockroachdb:master Mar 29, 2020
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.

DISTINCT doesn't work with jsonb_build_object

3 participants