Skip to content

fix unix_timestamp - #27007

Open
daviszhen wants to merge 11 commits into
matrixorigin:mainfrom
daviszhen:0812-fix-unix-timestamp
Open

fix unix_timestamp#27007
daviszhen wants to merge 11 commits into
matrixorigin:mainfrom
daviszhen:0812-fix-unix-timestamp

Conversation

@daviszhen

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:

issue #26979

What this PR does / why we need it:

• 本分支主要修改:

  • 修复 UNIX_TIMESTAMP() 对 typed TIMESTAMP(6) / DATETIME(6) 丢失微秒的问题。

  • TIMESTAMP/DATETIME 参数 scale > 0 时,UNIX_TIMESTAMP 返回 DECIMAL128(38,6),保留 fractional seconds。

  • scale = 0 时仍保持原来的 INT64 秒级返回。

  • 执行路径不再对 fractional temporal 直接调用 Timestamp.Unix(),改为用 epoch microseconds 构造 decimal 结果。

  • 补充 UT 覆盖:

    • TIMESTAMP(0) 返回 INT64
    • TIMESTAMP(6) / DATETIME(6) 返回 DECIMAL128(38,6)
    • 2024-02-29 23:59:59.999999 输出 1709251199.999999
    • zero timestamp 仍返回 NULL
  • 补充 BVT:

    • typed TIMESTAMP(6) / DATETIME(6) column 调用 UNIX_TIMESTAMP
    • TIMESTAMP(0) / DATETIME(0) 对照
    • FROM_UNIXTIME(UNIX_TIMESTAMP(ts6)) round trip 保留微秒。

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

Reviewed exact head f489ccf. The typed TIMESTAMP/DATETIME path now returns an exact decimal for fractional temporal inputs while preserving the existing integer result for scale 0 and the no-argument form. I checked planner scale propagation, DATETIME-to-TIMESTAMP timezone conversion, microsecond representation, zero/NULL/pre-epoch handling, constant/type behavior, and the full affected function package. All pkg/sql/plan/function tests pass and CI is green; no blocking correctness, lifecycle, or performance issue found.

@mergify mergify Bot added the queued label Aug 12, 2026
@mergify

mergify Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • Entered queue2026-08-12 15:52 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • Checks failed · in-place
  • 🚫 Left the queue2026-08-12 17:24 UTC · at 9018d323e01effa1d6d746e29bf435d5cba84f72

This pull request spent 1 hour 31 minutes 42 seconds in the queue, with no time running CI.

Waiting for
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
All conditions
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]

Reason

The merge conditions cannot be satisfied due to failing checks

Failing checks:

Hint

You may have to fix your CI before adding the pull request to the queue again.
If you update this pull request, to fix the CI, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

@LeftHandCold LeftHandCold left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed exact head f489ccf. The typed TIMESTAMP/DATETIME path now preserves fractional seconds as DECIMAL(38,6) while scale-0 and no-argument calls retain the existing INT64 behavior. I checked overload/type-scale propagation, DATETIME session-time-zone conversion, NULL/zero/pre-epoch boundaries, Decimal128 range, and normal-call compatibility; no blocking correctness, performance, or lifecycle issue found. CI is green. The focused local function test could not run because this isolated checkout does not contain cgo/libmo.dylib.

@aptend aptend 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.

Deep review completed on exact head f489ccfe545685381ea0b5e65717b531a14113ec. The typed TIMESTAMP/casted DATETIME path now derives a decimal result for fractional temporal scales and converts the internal epoch-microsecond representation directly, while preserving the existing integer/no-argument behavior at scale 0. I checked return-type and cast-scale propagation, timezone conversion for DATETIME, decimal scale/representation, zero/NULL/pre-epoch handling, upper-range safety, round-trip behavior, and existing review history. The full pkg/sql/plan/function suite and go vet pass with the required CGO artifacts, CI is green, and I found no blocking correctness or compatibility issue.

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/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants