pingcap / tidb

TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try AI-powered Chat2Query free at : https://www.pingcap.com/tidb-serverless/
https://pingcap.com
Apache License 2.0
36.32k stars 5.72k forks source link

json, expression: implicitly convert JSON string to time types #53363

Open YangKeao opened 2 weeks ago

YangKeao commented 2 weeks ago

What problem does this PR solve?

Issue Number: close #53243, close #53352

Problem Summary:

Two problem:

  1. TiDB didn't allow inserting json string as an item of DATE/DATETIME/TIMESTAMP array.
  2. TiDB didn't use the correct fsp when converting JSON to DATE/DATETIME/TIMESTAMP.

What changed and how does it work?

  1. Implicitly converting JSON string to DATE/DATETIME/TIMESTAMP when we are converting them to DATE/DATETIME/TIMESTAMP array.
  2. Deprecate the original method GetTime which uses the DefaultFsp, and implement a new method on BinaryJSON to return types.Time with the provided Fsp.

Check List

Tests

Side effects

Documentation

Release note

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

Fix the issue that JSON string array cannot be converted to DATE/DATETIME/TIMESTAMP array.
Fix the issue that when converting JSON to DATE/DATETIME/TIMESTAMP, the precision is ignored.
ti-chi-bot[bot] commented 2 weeks ago

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Once this PR has been reviewed and has the lgtm label, please assign windtalker for approval. For more information see the Code Review Process.

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

Needs approval from an approver in each of these files: - **[OWNERS](https://github.com/pingcap/tidb/blob/master/OWNERS)** - **[pkg/expression/OWNERS](https://github.com/pingcap/tidb/blob/master/pkg/expression/OWNERS)** Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
YangKeao commented 2 weeks ago

/hold

I remembered another issue: https://github.com/pingcap/tidb/issues/50370. I need to check whether this PR will bring some potential correctness issue later :thinking: .

codecov[bot] commented 2 weeks ago

Codecov Report

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

Project coverage is 74.5644%. Comparing base (1c4a9c6) to head (6abc68d). Report is 46 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #53363 +/- ## ================================================ + Coverage 72.4996% 74.5644% +2.0647% ================================================ Files 1505 1505 Lines 429646 430456 +810 ================================================ + Hits 311492 320967 +9475 + Misses 98849 89563 -9286 - Partials 19305 19926 +621 ``` | [Flag](https://app.codecov.io/gh/pingcap/tidb/pull/53363/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | Coverage Δ | | |---|---|---| | [integration](https://app.codecov.io/gh/pingcap/tidb/pull/53363/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `49.2237% <85.7142%> (?)` | | | [unit](https://app.codecov.io/gh/pingcap/tidb/pull/53363/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `71.3363% <80.9523%> (-0.0627%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap#carryforward-flags-in-the-pull-request-comment) to find out more. | [Components](https://app.codecov.io/gh/pingcap/tidb/pull/53363/components?src=pr&el=components&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | Coverage Δ | | |---|---|---| | [dumpling](https://app.codecov.io/gh/pingcap/tidb/pull/53363/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `53.9957% <ø> (ø)` | | | [parser](https://app.codecov.io/gh/pingcap/tidb/pull/53363/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `∅ <ø> (∅)` | | | [br](https://app.codecov.io/gh/pingcap/tidb/pull/53363/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `50.3892% <ø> (+8.9648%)` | :arrow_up: |
YangKeao commented 2 weeks ago

/retest

tiprow[bot] commented 2 weeks ago

@YangKeao: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
fast_test_tiprow 6abc68dae76fe0824c3a089fe32d911a56d1b5d0 link true /test fast_test_tiprow

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).