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: JSON_SCHEMA_VALID() #52780

Merged
merged 16 commits into from
Jun 3, 2024
Merged

Conversation

dveeden
Copy link
Contributor

@dveeden dveeden commented Apr 20, 2024

What problem does this PR solve?

Issue Number: close #52779

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.

Support for the `JSON_SCHEMA_VALID()` function was added.

@ti-chi-bot ti-chi-bot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/needs-triage-completed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 20, 2024
Copy link

tiprow bot commented Apr 20, 2024

Hi @dveeden. 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.

@dveeden
Copy link
Contributor Author

dveeden commented Apr 20, 2024

/check-issue-triage-complete

@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed do-not-merge/needs-triage-completed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 20, 2024
@dveeden
Copy link
Contributor Author

dveeden commented Apr 20, 2024

mysql> SELECT JSON_SCHEMA_VALID('{"required": ["a","b"]}', '{"a": 5,"c": 6}');
+-----------------------------------------------------------------+
| JSON_SCHEMA_VALID('{"required": ["a","b"]}', '{"a": 5,"c": 6}') |
+-----------------------------------------------------------------+
|                                                               0 |
+-----------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> SELECT JSON_SCHEMA_VALID('{"required": ["a","b"]}', '{"a": 5,"b": 6}');
+-----------------------------------------------------------------+
| JSON_SCHEMA_VALID('{"required": ["a","b"]}', '{"a": 5,"b": 6}') |
+-----------------------------------------------------------------+
|                                                               1 |
+-----------------------------------------------------------------+
1 row in set (0.00 sec)

Copy link

codecov bot commented Apr 21, 2024

Codecov Report

Attention: Patch coverage is 52.85714% with 33 lines in your changes are missing coverage. Please review.

Project coverage is 74.6520%. Comparing base (4a51974) to head (d87f556).
Report is 29 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #52780        +/-   ##
================================================
+ Coverage   70.8824%   74.6520%   +3.7696%     
================================================
  Files          1506       1506                
  Lines        412222     437594     +25372     
================================================
+ Hits         292193     326673     +34480     
+ Misses       100640      90912      -9728     
- Partials      19389      20009       +620     
Flag Coverage Δ
integration 50.2067% <44.2857%> (?)
unit 71.4131% <47.1428%> (+1.6020%) ⬆️

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

Components Coverage Δ
dumpling 53.9957% <ø> (-2.3014%) ⬇️
parser ∅ <ø> (∅)
br 50.2588% <ø> (+6.7060%) ⬆️

@dveeden
Copy link
Contributor Author

dveeden commented Apr 21, 2024

MySQL:

mysql> CREATE TABLE t (id INT PRIMARY KEY AUTO_INCREMENT, j JSON, CHECK(JSON_SCHEMA_VALID('{"type": "array"}', j)));
Query OK, 0 rows affected (0.01 sec)

mysql> INSERT INTO t VALUES (1, '[0,1,2,3,4]');
Query OK, 1 row affected (0.01 sec)

mysql> INSERT INTO t VALUES (1, '{}');
ERROR 3819 (HY000): Check constraint 't_chk_1' is violated.

TiDB:

mysql> SET GLOBAL tidb_enable_check_constraint=ON;
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE TABLE t (id INT PRIMARY KEY AUTO_INCREMENT, j JSON, CHECK(JSON_SCHEMA_VALID('{"type": "array"}', j)));
ERROR 3812 (HY000): An expression of non-boolean type specified to a check constraint 't_chk_1'.

Update: Already fixed

@dveeden dveeden requested a review from CbcWestwolf April 21, 2024 12:37
@ti-chi-bot ti-chi-bot bot added the sig/planner SIG: Planner label Apr 24, 2024
@hawkingrei
Copy link
Member

/ok-to-test

@ti-chi-bot ti-chi-bot bot added the ok-to-test Indicates a PR is ready to be tested. label Apr 24, 2024
@dveeden
Copy link
Contributor Author

dveeden commented May 28, 2024

/retest

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 lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels May 31, 2024
Copy link

ti-chi-bot bot commented May 31, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-04-30 10:40:52.260844455 +0000 UTC m=+353806.017980028: ☑️ agreed by hicqu.
  • 2024-05-31 05:54:33.477724917 +0000 UTC m=+3015027.234860490: ☑️ agreed by windtalker.

@easonn7
Copy link

easonn7 commented Jun 2, 2024

/approve

@dveeden dveeden requested a review from tangenta June 3, 2024 05:18
Copy link

ti-chi-bot bot commented Jun 3, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: easonn7, hawkingrei, hicqu, tangenta, windtalker

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm ok-to-test Indicates a PR is ready to be tested. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/planner SIG: Planner size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JSON schema validation with JSON_SCHEMA_VALID()
8 participants