Skip to content

fix(sql): round temporal integer casts and support unsigned targets - #32001

Merged
mergify[bot] merged 13 commits into
matrixorigin:mainfrom
ck89119:issue-31926-main
Nov 2, 2026
Merged

mergify[bot] merged 13 commits into
matrixorigin:mainfrom
ck89119:issue-31926-main

Conversation

@ck89119

@ck89119 ck89119 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

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

Which issue(s) this PR fixes:

Fixes #31926

What this PR does / why we need it:

Round explicit DATETIME, TIMESTAMP, and TIME integer casts in the calendar/clock domain before packing their numeric values, including fractional-second carries, negative TIME, and MySQL boundary behavior. Support DATE, DATETIME, and TIMESTAMP casts to UNSIGNED, and preserve the session time zone for TIMESTAMP.

Reuse the existing temporal integer-argument calculations without changing assignment, comparison, or DECIMAL conversion semantics. Lower integer evaluation at its value owner: stored temporal columns round; temporal CAST, COALESCE, IFNULL, LEAST, and GREATEST results honor TIME_TRUNCATE_FRACTIONAL; IF/CASE forward the selected branch's policy. Lower scalar outputs at their value owner before ordinary, outer-JOIN ON, or dependent materialization, keeping planner bindings and program output types aligned. Preserve null-extension, ordering, DISTINCT, and scalar cardinality. Rebind scalar alias graphs so ORDER BY/HAVING consumers cannot mutate the selected datetime or its output type. Carry the contract through folding, serialization, and prepared execution without duplicating conditions. Check resolved overload stability in RETURNING admission rather than rejecting every CAST by function name.

Update the existing DATE-to-UNSIGNED expectation and add focused UT/BVT coverage.

Validation:

  • Planner/function package tests, go vet, and incremental golangci-lint passed with Go 1.27.1.
  • Changed executable-line coverage for the PR: 94.4% (76.9% for the latest follow-up).
  • Temporal CAST BVT (106 statements) passed twice; existing CAST BVT (374 statements) and upstream temporal-context BVT (36 statements) passed after merging main.
  • SQL outputs and expected cardinality errors matched MySQL 8.4.11 exactly, including mixed/nested branches, string columns, stored-column controls, scalar subqueries (empty, correlated WHERE hit/miss, LEFT/RIGHT JOIN ON, nested dependent calls, shared aliases with DATETIME(6) metadata, ordered, DISTINCT), LEAST/GREATEST, time zones, and prepared-parameter SQL-mode/NULL changes.
  • RETURNING binding tests and EXPLAIN passed. An additional execution probe hit a resource-admission cap of 1, also reproduced with a no-CAST control; no successful RETURNING runtime result is claimed.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH

XuPeng-SH commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 13f3d032db68dbc8b905505ba79062bf4ddcf898

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

mo-bot review · mo-bot-local · review

Commit: 13f3d032db68dbc8b905505ba79062bf4ddcf898

Assessment: approve

Reviewed the complete change and affected consumers. Temporal rounding, unsigned conversion, scalar ownership, alias metadata and RETURNING admission are coherent. No actionable findings remain.

Model: gpt-6-astra / xhigh

Session: 01a1869d-820c-7212-9788-aecfb86a4141 · slot 0 · generation 2

Validation:

  • Reviewed all 19 changed files, linked issue requirements and both discussion entries; saved review-plan.md and discussion-assessment.json.

  • Passed 16 focused top-level tests across planner and function packages, including six diagnostic scalar-plan variants. Evidence: focused-probe-retry.log and checks/1793634419094278163-3.json.

  • Preflight passed. Verified 29 native input hashes, reconciled check receipts and confirmed unchanged source; see validation-evidence.json and validation-audit-retry.log.

  • Reused frozen-head successful build, unit-test, static-analysis and multi-CN BVT evidence.

Limitations:

  • No local end-to-end SQL or MySQL differential execution; author-reported differential results were not independently reproduced.

  • Local RETURNING checks cover binding and cast execution. The author's runtime check encountered an admission-cap limitation also present in its control.

@mergify mergify Bot added the queued label Nov 2, 2026
@mergify
mergify Bot merged commit b86ddaf into matrixorigin:main Nov 2, 2026
@mergify

mergify Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

✅ Merged into main as b86ddaf at 15:54 UTC

Less than a minute in the queue, with no time running CI.

So far

  • ✅ Entered the queue Mon 2 Nov, 15:54 · rule main · triggered by rule Automatic queue on approval for main
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged 15:54 · b86ddaf · squash
3 merge conditions met
  • #review-threads-unresolved = 0 · required by GitHub branch protection
  • github-review-approved · required by GitHub branch protection
  • any of · required by GitHub branch protection:
    • check-success = CI Required
    • check-neutral = CI Required
    • check-skipped = CI Required

Times in UTC · dashboard · how the merge queue works

@mergify mergify Bot removed the queued label Nov 2, 2026
gouhongshen added a commit to gouhongshen/matrixone that referenced this pull request Nov 2, 2026
…stream claimed 97 as narrow_scan in matrixorigin#32034); take upstream narrow-scan prefetch, virtual-timestamp reads, temporal integer casts, vector shuffle ownership, JSON concat and logtail append-range changes

GitHub reported the PR CONFLICTING (DIRTY): upstream matrixorigin#32034 added
`plan.Node.narrow_scan = 97` while this branch's unmerged additive
`ScanReadRole scan_read_role` sat on field 97.

Semantic resolution, both sides kept:
- upstream keeps `narrow_scan = 97` (shipped on main;
  `plan.pb.go` regenerated from the merged proto with the repository
  protoc/gogofast pipeline plus both postprocessors; toolchain verified
  byte-identical against upstream's committed bindings before use);
- this branch's additive `scan_read_role` moves 97 -> 98; nothing ever
  persisted 97 as scan_read_role (unmerged field), provenance comment
  updated in proto/plan.proto;
- `merged_descriptor_test.go` (upstream's merge-collision contract
  guard) extended to pin Node.narrow_scan=97 / Node.scan_read_role=98
  so a future regeneration cannot silently renumber or drop either;
- all other overlapping files auto-merged with both sides' hunks intact
  (upstream: table_scan/narrow-scan scope+operator plumbing, plan binder
  temporal/int-arg changes, disttae datasource, query_builder/types/
  deepcopy/base_binder/apply_indices).

Upstream batch: matrixorigin#31268 (virtual timestamp reads), matrixorigin#32001 (temporal
integer casts), matrixorigin#32020 (vector shuffle ownership), matrixorigin#32031 (logtail
append ranges), matrixorigin#32038 (python JSON-string concatenation; upstream's
own change, no PR-side code), matrixorigin#32034 (narrow-scan prefetch).
@ck89119
ck89119 deleted the issue-31926-main branch November 3, 2026 03:13

This branch was previously deployed

1 inactive deployment
ci — 13f3d032 Deployed Nov 2, 2026 by ck89119
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/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: CAST(DATETIME/TIMESTAMP/TIME with fractional seconds AS SIGNED) truncates instead of rounding; CAST(DATE/DATETIME AS UNSIGNED) is rejected

3 participants