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

opt: fix duplicate empty JSON value spans for <@ expressions #63355

Merged
merged 1 commit into from
Apr 9, 2021

Conversation

angelazxu
Copy link
Contributor

Previously, there were some duplicate spans produced for empty JSON values,
such as {"a": []} and {"a": {}}. This was discovered in the spans produced
from contained by and fetch/contained by expressions.

This commit fixes this issue, only allowing one empty object or array span to
be created per level of nesting, in encodedContainedInvertedIndexSpans.

Informs: #61430

Release note: None

@angelazxu angelazxu requested a review from a team as a code owner April 8, 2021 23:18
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor Author

@angelazxu angelazxu left a comment

Choose a reason for hiding this comment

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

Also, I'm not sure if isObjectValue is the best name for the boolean being passed in the functions, it's more like isNonEmptyObjectOrArrayValue (!isEnd), not sure if there's a more fitting yet simple name?

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

Copy link
Collaborator

@rytaft rytaft left a comment

Choose a reason for hiding this comment

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

Good find!

How about keeping the name isObjectValue, but making it actually mean that (i.e., you would pass true from the function calls inside jsonObject.encodeContainedInvertedIndexSpans())? Then you'd need to check if !isObjectValue || len(j) == 0. I think that should work, right?

Reviewed 3 of 3 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @angelazxu)

Copy link
Contributor Author

@angelazxu angelazxu left a comment

Choose a reason for hiding this comment

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

yup that works!! thanks :D

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

Copy link
Collaborator

@rytaft rytaft left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 2 of 2 files at r2.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @angelazxu)


pkg/util/json/json.go, line 108 at r2 (raw file):

	//
	// If isRoot is true, this function is being called at the root level of the
	// JSON hierarchy.

add a description of the isObjectValue param here

Previously, there were some duplicate spans produced for empty JSON values,
such as {"a": []} and {"a": {}}. This was discovered in the spans produced
from contained by and fetch/contained by expressions.

This commit fixes this issue, only allowing one empty object or array span to
be created per level of nesting, in encodedContainedInvertedIndexSpans.

Informs: cockroachdb#61430

Release note: None
@angelazxu
Copy link
Contributor Author

bors r+

@craig
Copy link
Contributor

craig bot commented Apr 9, 2021

Build succeeded:

@craig craig bot merged commit 71a023f into cockroachdb:master Apr 9, 2021
@angelazxu angelazxu deleted the fix_empty_spans1 branch April 9, 2021 21:19
@knz
Copy link
Contributor

knz commented Apr 13, 2021

this might benefit from a backport to the stable release branch(es).

@rytaft
Copy link
Collaborator

rytaft commented Apr 13, 2021

I think fixes a bug that was introduced after the branch cut for 21.1, so I don't think it needs a backport.

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.

4 participants