Skip to content

Conversation

@XuPeng-SH
Copy link
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #22701 #https://github.com/matrixorigin/MO-Cloud/issues/5761

What this PR does / why we need it:

How it fixes:

Add and use TruncateToScale for TIME; ensure Datetime/Timestamp/Time all apply scale consistently.
Update CAST paths:
Add timeToTime and datetimeToDatetime with TruncateToScale.
Modify datetimeToTimestamp to accept targetScale and apply TruncateToScale.
Ensure timestampToTimestamp/timestampToDatetime also apply target scale.
Built-ins: apply TruncateToScale in current_timestamp/sysdate (and NOW family) per explicit scale; default behaves as scale 0.
Type inference: restore scale=6 for string sources so literals keep full precision before truncation to target scale (MySQL 8.0 behavior).
Tests: fix incorrect expectations in unit tests; rework flaky NOW tests; update plan_cache to use TIMESTAMP(6); add comprehensive BVT suites for TIME/DATETIME/TIMESTAMP covering rounding, boundaries, negatives, casts, arithmetic, comparisons, and functions; remove PASS/FAIL strings in results and assert via value outputs.

Notes/impact:

Breaking change: TIMESTAMP(0)/DATETIME(0)/TIME(0) now truly store/compare at seconds resolution. Workloads relying on microsecond differences at scale 0 must switch to scale 6.
Aligns with MySQL 8.0 behavior; improves determinism; eliminates test flakiness.

…STAMP, align with MySQL 8.0, add comprehensive tests (matrixorigin#22708)

### How it fixes:
Add and use TruncateToScale for TIME; ensure Datetime/Timestamp/Time all apply scale consistently.
Update CAST paths:
Add timeToTime and datetimeToDatetime with TruncateToScale.
Modify datetimeToTimestamp to accept targetScale and apply TruncateToScale.
Ensure timestampToTimestamp/timestampToDatetime also apply target scale.
Built-ins: apply TruncateToScale in current_timestamp/sysdate (and NOW family) per explicit scale; default behaves as scale 0.
Type inference: restore scale=6 for string sources so literals keep full precision before truncation to target scale (MySQL 8.0 behavior).
Tests: fix incorrect expectations in unit tests; rework flaky NOW tests; update plan_cache to use TIMESTAMP(6); add comprehensive BVT suites for TIME/DATETIME/TIMESTAMP covering rounding, boundaries, negatives, casts, arithmetic, comparisons, and functions; remove PASS/FAIL strings in results and assert via value outputs.
### Notes/impact:
Breaking change: TIMESTAMP(0)/DATETIME(0)/TIME(0) now truly store/compare at seconds resolution. Workloads relying on microsecond differences at scale 0 must switch to scale 6.
Aligns with MySQL 8.0 behavior; improves determinism; eliminates test flakiness.

Approved by: @heni02, @ouyuanning
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants