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

partition: fix exchange partition validition check for null value #47208

Merged
merged 1 commit into from
Feb 28, 2024

Conversation

jiyfhust
Copy link
Contributor

@jiyfhust jiyfhust commented Sep 23, 2023

What problem does this PR solve?

Issue Number: close #47167

Problem Summary:

What is changed and how it works?

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 release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/needs-tests-checked do-not-merge/needs-triage-completed needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 23, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Sep 23, 2023

Hi @jiyfhust. Thanks for your PR.

I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@tiprow
Copy link

tiprow bot commented Sep 23, 2023

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

@jiyfhust
Copy link
Contributor Author

jiyfhust commented Sep 23, 2023

The "partition by range columns(a, b, c)" case is not fixed by this pr, it seems to be difficult to fix it directly in func buildCheckSQLConditionForRangeColumnsPartition.

Mayby we can handle it this way:

CREATE TABLE t1 (a int, b int, c int) partition by range columns(a, b, c)(
		partition p0 values less than (100, 1000, 10000), 
		partition p1 values less than (200, 2000, 20000),
		partition p2 values less than (maxvalue, null, null));
CREATE TABLE t2 (a int, b int, c int);

alter table t1 EXCHANGE PARTITION p0 WITH TABLE t2; 

the checksql:

select 1 from t2 where (a, b, c) >= (100, 1000, 10000) imit 1;

alter table t1 EXCHANGE PARTITION p1 WITH TABLE t2; 

the checksql:

select 1 from t2 where (a, b, c) < (100, 1000, 10000) or (a, b, c) >= (200, 2000, 20000) or a is null or a = 100 and b is null or c = 100 and b = 1000 and c is null limit 1;

alter table t1 EXCHANGE PARTITION p2 WITH TABLE t2; 

the checksql:
select 1 from t2 where (a, b, c) < (200, 2000, 20000) or a is null or a = 200 and b is null or c = 200 and b = 2000 and c is null limit 1;

@mjonss
Copy link
Contributor

mjonss commented Sep 24, 2023

/ok-to-test

@ti-chi-bot ti-chi-bot bot added ok-to-test Indicates a PR is ready to be tested. and removed needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Sep 24, 2023
@codecov
Copy link

codecov bot commented Sep 24, 2023

Codecov Report

Merging #47208 (083d566) into master (1f03420) will decrease coverage by 14.2552%.
Report is 78 commits behind head on master.
The diff coverage is 100.0000%.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #47208         +/-   ##
=================================================
- Coverage   70.5752%   56.3200%   -14.2552%     
=================================================
  Files          1467       1584        +117     
  Lines        434756     620919     +186163     
=================================================
+ Hits         306830     349702      +42872     
- Misses       108651     248388     +139737     
- Partials      19275      22829       +3554     
Flag Coverage Δ
integration 38.7939% <28.5714%> (?)
unit 71.9317% <100.0000%> (+1.5631%) ⬆️

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

Components Coverage Δ
dumpling 53.9957% <ø> (ø)
parser ∅ <ø> (∅)
br 51.1660% <ø> (+5.3119%) ⬆️

@mjonss
Copy link
Contributor

mjonss commented Sep 24, 2023

The "partition by range columns(a, b, c)" case is not fixed by this pr, it seems to be difficult to fix it directly in func buildCheckSQLConditionForRangeColumnsPartition.
...

I thing you are on the right path, here is an example how an expression can be rewritten.

Please feel free to split out the RANGE COLUMS case from this PR.

ddl/partition.go Outdated
Comment on lines 3583 to 3585
buf.WriteString(" < %? or ")
buf.WriteString(pi.Expr)
buf.WriteString(" is null")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can there be a case where the expression string also would need to be wrapped into parentheses?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have to say i'm not sure about it. I tested partition by range (id+1), the expression is already wapped. And if pi.Expr is null needed, then pi.Expr < %? seems also needs. I think we can keep it now before we can make sure some cases as you described exist.

@jiyfhust jiyfhust force-pushed the fix_exchange_check_nullvalue branch from 9db794b to 4631110 Compare October 27, 2023 22:49
@jiyfhust
Copy link
Contributor Author

/test unit-test

@tiprow
Copy link

tiprow bot commented Oct 27, 2023

@jiyfhust: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test tiprow_fast_test

Use /test all to run all jobs.

In response to this:

/test unit-test

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.

@mjonss
Copy link
Contributor

mjonss commented Nov 14, 2023

/retest

@jiyfhust
Copy link
Contributor Author

@mjonss I think maybe we can review this pr as present.

@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 8, 2023
Copy link

ti-chi-bot bot commented Dec 8, 2023

PR needs rebase.

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 added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Feb 8, 2024
@jiyfhust
Copy link
Contributor Author

/test check-dev2

Copy link

tiprow bot commented Feb 19, 2024

@jiyfhust: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test tidb_parser_test
  • /test tiprow_fast_test

Use /test all to run all jobs.

In response to this:

/test check-dev2

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.

@jiyfhust
Copy link
Contributor Author

/cc @tiancaiamao
PTAL

@ti-chi-bot ti-chi-bot bot requested a review from tiancaiamao February 19, 2024 10:14
@jiyfhust jiyfhust force-pushed the fix_exchange_check_nullvalue branch from 31991ae to 083d566 Compare February 21, 2024 12:42
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Feb 27, 2024
Copy link

ti-chi-bot bot commented Feb 27, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-02-08 09:36:42.713352806 +0000 UTC m=+435928.280122695: ☑️ agreed by mjonss.
  • 2024-02-27 08:09:07.408164005 +0000 UTC m=+949436.155787115: ☑️ agreed by tiancaiamao.

@jiyfhust
Copy link
Contributor Author

/label-remove needs-rebase

@jiyfhust
Copy link
Contributor Author

/testall

@jiyfhust
Copy link
Contributor Author

/retest

@jiyfhust
Copy link
Contributor Author

PTAL @ti-chi-bot

@jiyfhust
Copy link
Contributor Author

/test all

@jiyfhust
Copy link
Contributor Author

@jebter @aytrack Please remove the needs-rebase lable, it can't be auto removed by ti-chi-bot.

@jiyfhust
Copy link
Contributor Author

/check-issue-triage-complete

@jebter
Copy link

jebter commented Feb 27, 2024

@jebter @aytrack Please remove the needs-rebase lable, it can't be auto removed by ti-chi-bot.

@wuhuizuo PTAL

@jiyfhust
Copy link
Contributor Author

please assign wjhuang2016 for approval

/cc @wjhuang2016

@ti-chi-bot ti-chi-bot bot requested a review from wjhuang2016 February 27, 2024 09:15
Copy link

ti-chi-bot bot commented Feb 27, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mjonss, tiancaiamao, wjhuang2016

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 the approved label Feb 27, 2024
@tiancaiamao tiancaiamao removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 28, 2024
@tiancaiamao
Copy link
Contributor

/merge

Copy link

ti-chi-bot bot commented Feb 28, 2024

@tiancaiamao: We have migrated to builtin LGTM and approve plugins for reviewing.

Please use /approve when you want approve this pull request.

The changes announcement: LGTM plugin changes

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 ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot bot merged commit f505eda into pingcap:master Feb 28, 2024
22 of 24 checks passed
@jiyfhust jiyfhust deleted the fix_exchange_check_nullvalue branch February 28, 2024 06:00
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-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.

Exchange List Partition add validition check tests for null value handling and default partition
5 participants