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

planner/core: support partition pruning for partition expression floor(unix_timestamp()) #16402

Merged
merged 5 commits into from
Apr 17, 2020

Conversation

tiancaiamao
Copy link
Contributor

@tiancaiamao tiancaiamao commented Apr 15, 2020

What problem does this PR solve?

Issue Number: close #16354

Problem Summary:

Support partition pruning for floor(unix_timestamp()

create table t (ts timestamp(3)) partition by range (floor(unix_timestamp(ts))) (
...)

What is changed and how it works?

What's Changed:

Take function floor(unix_timestamp()) as monotoneIncFuncs, special handle for this case.

How it Works:

If the partition function is monotoneous, i.e.

for all x > y => f(x) > f(y)

That partition function can be used by the partition pruning algorithm.

If we view floor(unix_timestamp()) as a single function, it basicly conform to the definition.

for all x > y => f(x) >= f(y)

Related changes

  • PR to update pingcap/docs/pingcap/docs-cn:
  • PR to update pingcap/tidb-ansible:
  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test
  • Integration test

Release note

@tiancaiamao tiancaiamao added type/enhancement The issue or PR belongs to an enhancement. needs-cherry-pick-3.0 labels Apr 15, 2020
@tiancaiamao tiancaiamao requested a review from a team as a code owner April 15, 2020 07:45
@ghost ghost requested review from eurekaka and removed request for a team April 15, 2020 07:45
@tiancaiamao
Copy link
Contributor Author

PTAL @imtbkcat

@tiancaiamao
Copy link
Contributor Author

/run-all-tests

@zz-jason zz-jason requested a review from XuHuaiyu April 15, 2020 08:09
@tiancaiamao tiancaiamao changed the title planner/core: support partition pruning for partition expression floor(timestamp()) planner/core: support partition pruning for partition expression floor(unix_timestamp()) Apr 15, 2020
@jackysp
Copy link
Member

jackysp commented Apr 15, 2020

PTAL @eurekaka @XuHuaiyu

@tiancaiamao
Copy link
Contributor Author

PTAL @XuHuaiyu @lysu

Copy link
Contributor

@lysu lysu left a comment

Choose a reason for hiding this comment

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

LGTM

to meet "floor(unix_timestamp()) requirement" now, but maybe we handle other functions in future - -?

@lysu lysu added status/LGT1 Indicates that a PR has LGTM 1. status/PTAL labels Apr 17, 2020
imtbkcat
imtbkcat previously approved these changes Apr 17, 2020
Copy link

@imtbkcat imtbkcat left a comment

Choose a reason for hiding this comment

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

LGTM

@jackysp
Copy link
Member

jackysp commented Apr 17, 2020

Please resolve conflicts.

@sre-bot sre-bot added the status/can-merge Indicates a PR has been approved by a committer. label Apr 17, 2020
@jackysp jackysp removed the status/can-merge Indicates a PR has been approved by a committer. label Apr 17, 2020
@tiancaiamao tiancaiamao added status/LGT2 Indicates that a PR has LGTM 2. status/can-merge Indicates a PR has been approved by a committer. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Apr 17, 2020
@sre-bot
Copy link
Contributor

sre-bot commented Apr 17, 2020

/run-all-tests

@sre-bot
Copy link
Contributor

sre-bot commented Apr 17, 2020

@tiancaiamao merge failed.

@codecov
Copy link

codecov bot commented Apr 17, 2020

Codecov Report

Merging #16402 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #16402   +/-   ##
===========================================
  Coverage   80.5864%   80.5864%           
===========================================
  Files           506        506           
  Lines        137445     137445           
===========================================
  Hits         110762     110762           
  Misses        18129      18129           
  Partials       8554       8554           

@tiancaiamao
Copy link
Contributor Author

/run-integration-copr-test

Copy link
Member

@jackysp jackysp left a comment

Choose a reason for hiding this comment

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

LGTM

@tiancaiamao
Copy link
Contributor Author

/run-unit-test

@jackysp
Copy link
Member

jackysp commented Apr 17, 2020

/merge

@sre-bot
Copy link
Contributor

sre-bot commented Apr 17, 2020

/run-all-tests

@sre-bot sre-bot merged commit d8e6cf8 into pingcap:master Apr 17, 2020
sre-bot pushed a commit to sre-bot/tidb that referenced this pull request Apr 17, 2020
Signed-off-by: sre-bot <sre-bot@pingcap.com>
@sre-bot
Copy link
Contributor

sre-bot commented Apr 17, 2020

cherry pick to release-3.0 in PR #16521

@tiancaiamao tiancaiamao deleted the floor-timestamp branch April 17, 2020 08:19
sre-bot pushed a commit to sre-bot/tidb that referenced this pull request Apr 17, 2020
Signed-off-by: sre-bot <sre-bot@pingcap.com>
@sre-bot
Copy link
Contributor

sre-bot commented Apr 17, 2020

cherry pick to release-3.1 in PR #16522

sre-bot pushed a commit to sre-bot/tidb that referenced this pull request Apr 17, 2020
Signed-off-by: sre-bot <sre-bot@pingcap.com>
@sre-bot
Copy link
Contributor

sre-bot commented Apr 17, 2020

cherry pick to release-4.0 in PR #16523

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle partition pruning for the floor(unix_timestamp()) expression
5 participants