-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
schemadiff
: temporal range partition rotation analysis and operation
#17426
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
go/mysql/datetime/datetime.go
Outdated
@@ -778,3 +778,14 @@ func NewDateTimeFromStd(t time.Time) DateTime { | |||
Time: NewTimeFromStd(t), | |||
} | |||
} | |||
|
|||
func NewDateTimeFromSeconds(seconds decimal.Decimal) DateTime { | |||
secondsInt64, _ := seconds.Int64() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should make sure to also include sub-second precision here. I would expect a general conversion function to honor that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already reverted :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decided to never reverse-engineer a function value; always compute forward.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #17426 +/- ##
==========================================
+ Coverage 67.60% 67.69% +0.09%
==========================================
Files 1581 1583 +2
Lines 253945 254775 +830
==========================================
+ Hits 171670 172462 +792
- Misses 82275 82313 +38 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Description
This PR introduces elaborate analysis and operations over temporal range partitioned tables.
Temporal range partitioned tables are tables with range partitions using any form of temporal value, ie:
PARTITION BY RANGE COLUMNS (col_name)
over a single column of typeDATE
orDATETIME
PARTITION BY RANGE (temporal_func(col_name))
using one of several explicitly supported functions:TO_SECONDS
TO_DAYS
YEAR
8.4
:UNIX_TIMESTAMP
and using aTIMESTAMP
columnschemadiff
then offers:AnalyzeTemporalRangePartitioning()
returningTemporalRangePartitioningAnalysis
, which determines whether the table is at all partitioned byRANGE
, and can be considered as being temporal partitioned. Analysis includes the minimal rotation interval, the function used, if any, the column used, whetherMAXVALUE
is used, etc.TemporalRangePartitioningNextRotation()
, given a table, interval, expected ahead-of-time partitions and time reference, returning a list ofALTER TABLE
statements that prepare futuristic empty partitions, as needed.schemadiff
analyzes the actual values in the table definition, whether these areDATE
,DATETIME
, or product of one of the supported functions, to determine which of the ahead-of-time partitions are already covered by existing schema, and which needs to be added.The function generates either
ADD PARTITION
orREORGANIZE PARTITION
statements, based on whetherMAXVALUE
partition is present.There's a variety of conditions to make the function return an error: if the table is not temporal range partitioned, if the interval is invalid for the table, and more.
TemporalRangePartitioningRetention()
: given a table and an expiration time, this function returns a (possibly empty)ALTER TABLE DROP PARTITION ...
statement dropping all expired partitions. Again,schemadiff
computed the actual partition values whether explicitDATE
,DATETIME
or product of one of the supported functions.Related Issue(s)
Checklist
Deployment Notes