Skip to content

fix(sql): return NULL for invalid DATE and DATETIME expressions - #30547

Merged
mergify[bot] merged 5 commits into
matrixorigin:mainfrom
iamlinjunhong:codex/loom/develop/75d12c50f7d818bd2a2dd21c81131f3e47c0d2034b65ad0f0e417a34acfe9a7e
Oct 19, 2026
Merged

mergify[bot] merged 5 commits into
matrixorigin:mainfrom
iamlinjunhong:codex/loom/develop/75d12c50f7d818bd2a2dd21c81131f3e47c0d2034b65ad0f0e417a34acfe9a7e

Conversation

@iamlinjunhong

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:

What this PR does / why we need it:

Invalid DATE and string-to-DATETIME expressions now return NULL for the affected row instead of aborting the query. This also covers ordinary DATETIME coercions used by DATE_FORMAT and CONVERT_TZ. Mark these expressions nullable so IS NULL, COUNT and COALESCE work with NOT NULL string sources.

Keep the shared parser strict and preserve assignment/IGNORE behavior, zero-date SQL-mode policy and temporal precision. Dedicated comparison/set-operation cast modes retain their existing errors. This change does not add MySQL warning 1292 parity or incomplete-date representation support.

Validation on macOS arm64 with Go1.27.1: focused regression and full function-package tests; incremental go vet and golangci-lint; seven affected BVT cases passed twice in normal comparison mode, plus tuple-comparison and typed Starlark assignment controls (2669 successful statement comparisons total). New regressions fail against the original production sources. CI is pending.

@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 Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-xupeng · done

Commit: 997cb6e195fe73ba0a58eaaa3ba76e61a62baed0

Review completed. Read the assessment.

@XuPeng-SH

XuPeng-SH commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 997cb6e195fe73ba0a58eaaa3ba76e61a62baed0

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: 997cb6e195fe73ba0a58eaaa3ba76e61a62baed0

Assessment: approve

Reviewed all 17 changed files and affected callers. NULL synthesis belongs in the existing expression converters, while the shared parser remains strict. Planner nullability matches the new behavior; assignment, precision, zero-date policy and error handling remain coherent. No actionable findings.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1

Validation:

  • Reused frozen exact-head successful UT, coverage, static-analysis and distributed BVT statuses; reviewed the added tests and changed result expectations.

  • Isolation preflight, fresh repository-owned native build and native provenance verification passed.

  • Independent public SQL probe passed: serial and admitted two-reader strict LOAD both rejected malformed DATETIME input and persisted zero rows. Receipt: 1792423936767177734-3.json.

  • Final audit verified unchanged source, matching change hunks, 11,510 archived files and 190 native inputs, and reconciled command/exit receipts with retained logs. Audit receipt: 1792424127497697067-4.json.

  • Evidence index: /home/xupeng/.local/state/mo-bot/jobs/fd7f8f57871e73f9a3dc3941/attempt-1/review-evidence.json.

Limitations:

  • Broad suites were reused from frozen CI evidence rather than repeated locally. Author per-case logs and the linked issue’s full body were not supplied.

  • Warning-1292 parity and incomplete-date support remain explicitly outside scope.

  • No benchmark was needed: valid conversions retain one parse per row with no new I/O, synchronization or retained state.

@mergify mergify Bot added the queued label Oct 19, 2026
@mergify

mergify Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-19 15:36 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-10-19 22:49 UTC · at 8dd623e7d7338669f1ae2c63ef555f17ec93a5d8 · squash

This pull request spent 7 hours 13 minutes 10 seconds in the queue, including 50 minutes 37 seconds running CI.

Required conditions to merge

@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-xupeng · review

Commit: 997cb6e195fe73ba0a58eaaa3ba76e61a62baed0

Assessment: approve

Reviewed the complete 17-file delta and affected callers. NULL-producing DATE/DATETIME conversions align with planner nullability, while strict parsing, assignment, restricted cast modes, zero-date policy and precision remain intact. No actionable findings.

Model: gpt-6-astra / xhigh

Session: 01a15209-2c6d-71e2-b8f3-aa17387fa283 · slot 2 · generation 0

Validation:

  • Verified the frozen HEAD, unchanged checkout and complete patch, allowing coordinator-trimmed terminal whitespace.

  • Isolation preflight passed. Recovered compatible native prerequisites after verifying all 272 build inputs and seven library hashes.

  • Passed 14 selected regression tests across function, plan and issues packages with -count=1, -vet=all and the assigned test executor. Coverage includes malformed rows, selection masks, nullability, precision, zero dates, assignment, resolver errors and real SQL prepared-statement reuse.

  • Commands, source fingerprints, successful exit receipts and retained logs were reconciled in /home/xupeng/.local/state/mo-bot/jobs/0007ed865a9e8fd98e843ce0/attempt-1/validation-audit.json.

  • Reviewed all seven affected BVT case/result changes. Frozen CI metadata reports successful Linux UT, static analysis and multi-CN BVT checks.

Limitations:

  • Full BVT and repository suites were not rerun locally; raw CI and author validation logs were not supplied.

  • The linked issue #30537 body was unavailable. Assessment covers the supplied PR contract, which explicitly excludes warning 1292 parity and incomplete-date representation.

@aunjgr aunjgr 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 997cb6e independently. No blocking finding.

The NULL synthesis is confined to expression conversions, with matching planner nullability. Shared parsing remains strict; assignment/IGNORE, dedicated comparison/set-operation modes, zero-date policy, precision, resolver failures and masked rows retain their separate contracts. The prepared lower/upper-bound recovery and NOT NULL-source consumer tests cover important downstream effects.

Reviewed the changed unit/public SQL expectations and reused passing exact-head CI; no new local cluster run is claimed. Warning-1292 parity and incomplete-date representation are explicitly not being approved as part of this focused fix.

@mergify
mergify Bot merged commit 8dd623e into matrixorigin:main Oct 19, 2026
@mergify mergify Bot removed the queued label Oct 19, 2026
XuPeng-SH pushed a commit that referenced this pull request Oct 29, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

- #30537

## What this PR does / why we need it:

Invalid temporal text in DATE, DATETIME, TIME and DATE_FORMAT
expressions returns the appropriate NULL or recoverable TIME result with
warning 1292, including mixed rows and prepared statements. Preserve
diagnostics through expression evaluation, filtering, folding and remote
execution, while keeping assignment and other existing conversion
policies separate.

This builds on #30547, which returned NULL for invalid DATE and DATETIME
expressions but explicitly left warning 1292 parity out of scope.

Validation on macOS arm64 includes function, colexec, plan, compile,
rule and filter package tests; focused prepared-statement tests; two
normal-comparison runs each of the affected DATE and temporal
consistency BVT files; MySQL 8.0.46 comparison; and a two-CN test of one
peer producing and returning projection diagnostics. The function BVT
directory did not fully pass: two timestamp assertions failed in a
timezone-order-dependent case. Multi-CN coverage does not test
coordinator exchange or simultaneous production by multiple peers. Wire
metadata and temporal-specific max_error_count=0/1 combinations were not
newly verified.

A single-CN warm-cache valid DATE column predicate comparison measured a
4.9% median increase (five samples); this does not establish performance
across other workloads or topologies. Invalid DATE constants incur
approximately 3.04 µs and 1084 bytes per row for diagnostics. CI passed
at `161acd120e8aacd6affbb04f3f90ed4f7e36d103` ([run
40862615124](https://github.com/matrixorigin/matrixone/actions/runs/40862615124)).

Repair validation at `161acd120e8aacd6affbb04f3f90ed4f7e36d103` (macOS
arm64, Go 1.27.1): new full package runs for plan, MongoDB, EXPLAIN,
Substrait and compile passed with `mo-cgo-test -vet=all -count=1`.
Focused `-short -tags=matrixone_test -covermode=set -cover` regressions
passed, as did temporal SQL integration (including binary prepared
statements and SQL PREPARE/EXECUTE) and
`TestIssue30537TemporalWarningsPeerCN` with forced peer placement.
Incremental golangci-lint over the PR package closure reports 0 issues.
Function, colexec and rule package results are reused for their
unchanged kernel/executor inputs. The repair preserves safe temporal
constant planning, strict TIME comparison policy, MongoDB DATETIME
predicate pushdown and failure-safe test cleanup. Full Linux Compose BVT
and repository-wide coverage were not rerun locally.

Prepared GAPFILL repair validation at
`e3cf275e9bc51c8a07c45cf8de3ec77f51be60b5` (macOS arm64, Go 1.27.1):
reproduced missing DATE/DATETIME bounds and an empty-range query
returning 3 rows directly but 0 through parameterless binary
preparation. Runtime-constant bounds now survive PREPARE; private grid
evaluation preserves WHERE diagnostic ownership. New normal package runs
for plan, timewin, EXPLAIN and compile passed with `mo-cgo-test -vet=all
-count=1`; temporal SQL integration verifies direct, binary prepared and
SQL PREPARE/EXECUTE results on empty and partitioned input, including
cached repetition. A bound reset test covers invalid/valid/invalid
inputs without extra warnings. Incremental golangci-lint on the three
changed packages reports 0 issues. Earlier CI and kernel/remote
validation are reused for unchanged inputs; full Linux Compose and
coverage were not rerun locally for this repair.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

This branch was previously deployed

1 inactive deployment
ci — ce70228f Deployed Oct 19, 2026 by mergify[bot]
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.

4 participants