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

expression: fix the incorrect result of json_length(cast(1 as json), null) #50933

Merged
merged 7 commits into from
Feb 4, 2024

Conversation

SeaRise
Copy link
Contributor

@SeaRise SeaRise commented Feb 2, 2024

What problem does this PR solve?

Issue Number: close #50931

Problem Summary:

What changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot bot added do-not-merge/invalid-title do-not-merge/needs-triage-completed do-not-merge/needs-tests-checked release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 2, 2024
Copy link

tiprow bot commented Feb 2, 2024

Hi @SeaRise. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@SeaRise SeaRise changed the title fix the incorrect result of json_length(cast(1 as json), null) expression: fix the incorrect result of json_length(cast(1 as json), null) Feb 2, 2024
Copy link

codecov bot commented Feb 2, 2024

Codecov Report

Merging #50933 (64fe766) into master (9aabf72) will increase coverage by 2.1248%.
Report is 6 commits behind head on master.
The diff coverage is 100.0000%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #50933        +/-   ##
================================================
+ Coverage   70.5281%   72.6529%   +2.1248%     
================================================
  Files          1466       1466                
  Lines        434112     434511       +399     
================================================
+ Hits         306171     315685      +9514     
+ Misses       108699      98929      -9770     
- Partials      19242      19897       +655     
Flag Coverage Δ
integration 48.9971% <75.0000%> (?)
unit 70.3140% <100.0000%> (-0.0261%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 54.1120% <ø> (ø)
parser ∅ <ø> (∅)
br 51.2850% <ø> (+5.5164%) ⬆️

@ti-chi-bot ti-chi-bot bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 2, 2024
@ti-chi-bot ti-chi-bot bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Feb 2, 2024
@SeaRise
Copy link
Contributor Author

SeaRise commented Feb 2, 2024

/check-issue-triage-complete

@SeaRise
Copy link
Contributor Author

SeaRise commented Feb 2, 2024

/cc @windtalker

@ti-chi-bot ti-chi-bot bot requested a review from windtalker February 2, 2024 09:13
@@ -860,6 +851,11 @@ func (b *builtinJSONLengthSig) vecEvalInt(ctx EvalContext, input *chunk.Chunk, r
return types.ErrInvalidJSONPathMultipleSelection
}

jsonItem := jsonBuf.GetJSON(i)
if jsonItem.TypeCode != types.JSONTypeCodeObject && jsonItem.TypeCode != types.JSONTypeCodeArray {
Copy link
Contributor

Choose a reason for hiding this comment

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

In non-vector version, if path does not exists, it returns null, but in the vector version, if the jsonItem is not JSON object or JSON array, it returns 1 even if path does not exists? According to MySQL's behavior, the non-vector version is right.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

result.MergeNulls(pathBuf) has been call in L839, so if path is null, continue will be call in L843

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean the path is not null, but a non exists path. Like select json_length(cast(1 as json), '$.a')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

get! fixed and added test case.

Copy link
Member

@YangKeao YangKeao left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Feb 2, 2024
Copy link
Contributor

@windtalker windtalker left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot bot added the lgtm label Feb 4, 2024
Copy link

ti-chi-bot bot commented Feb 4, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: windtalker, YangKeao

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added approved and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Feb 4, 2024
Copy link

ti-chi-bot bot commented Feb 4, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-02-02 10:54:58.888737923 +0000 UTC m=+1735740.453035628: ☑️ agreed by YangKeao.
  • 2024-02-04 01:33:49.103827449 +0000 UTC m=+61354.670597342: ☑️ agreed by windtalker.

@SeaRise
Copy link
Contributor Author

SeaRise commented Feb 4, 2024

/retest

Copy link

tiprow bot commented Feb 4, 2024

@SeaRise: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ti-chi-bot ti-chi-bot bot merged commit a9e9642 into pingcap:master Feb 4, 2024
23 checks passed
@SeaRise SeaRise deleted the json_length_2_arg branch February 4, 2024 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The result of json_length(cast(1 as json), null) isn't same as mysql
3 participants