Skip to content

fix(function): support row-dependent CONV bases - #28754

Merged
mergify[bot] merged 10 commits into
matrixorigin:mainfrom
aunjgr:fix/conv-row-bases-28576
Sep 14, 2026
Merged

mergify[bot] merged 10 commits into
matrixorigin:mainfrom
aunjgr:fix/conv-row-bases-28576

Conversation

@aunjgr

@aunjgr aunjgr commented Sep 12, 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 #28576

What this PR does / why we need it:

CONV previously required constant INT64 bases and read them only at row zero. Integer columns of other widths and uncast prepared base parameters could fail during binding, while BIGINT columns and row-dependent expressions failed during execution.

Normalize base argument types locally to CONV, preserving the first argument's source domain and retaining UINT64 bases without a narrowing signed cast. Read and validate each row's bases before conversion; NULL and out-of-range bases return NULL for that row, including signed and unsigned extremes. Preserve selection masks, existing numeric-prefix and BIT conversion semantics, and the cached constant-base path.

Retain existing function overload identities. Require MORPC capability 70 for nonconstant or unsigned base execution shapes, probe the selected workers, and keep execution local when capability is unavailable. Recheck the actual destination before sending and validate the encoded expression at the receiver. Previously supported literal INT64 bases do not require the new capability.

Cover typed inputs, integer-width coercion, NULL/invalid/masked rows, SQL and binary prepared statements, actual pipeline serialization, capability downgrade and local fallback, response cleanup, and real two-CN execution. Include a constant-base benchmark to guard the existing hot path.

…cement

Accept integer columns and prepared base arguments without changing the first operand conversion domain. Validate signed and unsigned bases per row before narrowing, preserve NULL and selection behavior, and retain the constant-base fast path. Fence new base execution shapes with a worker capability probe, local fallback, and send-time destination recheck while keeping existing overload IDs. Cover typed inputs, integer extremes, SQL and binary prepare, actual remote serialization, downgrade fallback, response cleanup, and constant-base performance.
@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 →

…28576

# Conflicts:
#	pkg/defines/const.go
#	pkg/pb/plan/string_literal_form.go
#	pkg/sql/compile/remoterun.go
Extend the existing typed-input matrix with row-dependent invalid source bases, NULL destination bases, and invalid destination bases. Verify per-row NULL output without changing the valid-value oracles. Test the capability-66 fallback against current-main version 65 workers. The unchanged CI parser and rules report 76.92 percent changed-code coverage with local owning-package profiles.
@aunjgr

aunjgr commented Sep 12, 2026

Copy link
Copy Markdown
Contributor Author

Updated in fedbd28 on newest main.

The coverage gap was in the NULL/invalid-base branches of the typed CONV loops. The existing typed-input matrix now checks invalid source bases, NULL destination bases, and invalid destination bases for every input family, retaining all valid-value assertions. With the exact CI parser and unchanged inclusion rules, local owning-package profiles cover 110/143 changed blocks (76.92%), above 75%.

Main now owns protocol 65 for ASCII and 66 for GROUP_CONCAT row provenance. This PR's capability is 67; tests verify fallback against current-main66 workers and preserve the older contracts. Function, planner, compile, protocol and real two-CN/prepared tests pass, as does full SCA. Fresh CI will calculate its own final verdict.

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

[P1] Allocate a unique cumulative MORPC capability version before approval.

This PR now advertises MORPC v67 as support for row-dependent/unsigned CONV bases (pkg/defines/const.go:105-106, conv_bases_protocol.go), while the concurrently reviewable #28704 at head cc542142f39baf6868cc195ec8b4316e30cee764 also advertises v67 for checked integer arithmetic. The feature gates only compare the numeric version (remoteWorkersSupportProtocol, expression_protocol.go:93); they do not negotiate per-feature capabilities. The #28704 worker still rejects non-constant CONV bases (pkg/sql/plan/function/func_binary.go:3193-3195) and does not recognize RowDependentConvBases. Thus when a v67 arithmetic-only worker is selected, this PR's planner and send-time recheck treat it as CONV-capable and dispatch CONV(n, f, 10) with a row-dependent base; the remote worker then fails with conv bases not constant instead of taking the local fallback.

Please coordinate a single cumulative version allocation: either rebase this PR on the v67 arithmetic owner and assign CONV the next unique version, or define/test one combined v67 rollout that guarantees both capabilities before any peer advertises 67. Do not just raise MORPCLatestVersion while leaving the older feature outside the receiver implementation. Add an integration/compatibility test with a peer that reports v67 for arithmetic but lacks row-dependent CONV, and verify planner fallback or rejection before send. Isolated PR CI cannot expose this collision.

@aunjgr

aunjgr commented Sep 12, 2026

Copy link
Copy Markdown
Contributor Author

@XuPeng-SH The collision is real if binaries from those two unmerged branches are mixed, but that is not a supported deployment configuration. The agreed compatibility boundary is main/release builds only; we are not claiming arbitrary unmerged PR binaries can safely form a cluster.

These PRs must remain independent. The first one merged establishes the next cumulative MORPC version on main. Every later PR must merge that updated main, retain the already-landed implementation, allocate the next version, and rerun its compatibility tests before landing. Merely increasing the number without incorporating the preceding main implementation would indeed be wrong; that is not the delivery policy.

For this PR's current main/release boundary, the tests verify that main v66 workers lacking row-dependent CONV cause local placement, and that a destination downgrade is rejected before send. A separate test treating an arithmetic-only, unmerged v67 build as a supported release peer would assert a contract we explicitly do not offer.

I will not stack the unrelated arithmetic change into this PR or add a new feature-negotiation framework to support unsupported development-branch mixtures. Please reassess this finding against the main/release compatibility contract; the cumulative version will be finalized against main at merge time.

@aunjgr
aunjgr requested a review from XuPeng-SH September 12, 2026 15:41

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

Reviewed exact head fedbd28c57cd1c5f6316a197bc202eb55111af9a against base 0002cd5928271388ffb83ef3ec9d30226dcd1119.

No blocking issues found. I verified the per-row signed/unsigned base readers, invalid/NULL and selection handling across every typed CONV loop, binder casts for common integer/string base types, and the full placement/send/receive mixed-version fencing. Existing literal INT64 plans remain on the compatible path; row-dependent or UINT64 bases fail closed or fall back locally for pre-v67 workers.

I also reviewed the concurrent v67 concern independently. At this exact base, latest is v66, and the competing same-base v67 patches modify the same cumulative version allocation. They cannot both land unchanged as a valid cumulative build; whichever lands later must rebase on current main, retain the already-landed capability, and allocate the next version. Mixing arbitrary unmerged branch binaries is not a supported rolling-upgrade state, so I do not consider that a blocker for this exact head.

Validation passed:

  • focused CONV / expression-protocol unit tests in pkg/sql/plan/function, pkg/pb/plan, and pkg/sql/compile
  • embedded two-CN TestConvRowBasesRemoteFallback, including real remote execution, v66 local fallback, and prepared parameters
  • git diff --check and gofmt diff check

@aunjgr

aunjgr commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

Fixed the coverage failure and main conflicts in 21b0c89. The previous CI result was exactly75%, which fails the strict >75% gate. The existing typed CONV matrix now covers small signed/unsigned widths, DATE/TIME inputs, and selected/masked result reuse while preserving all NULL, invalid-base, and exact-value checks. With the same CI parser and unchanged inclusion rules, final owning-package profiles cover88/109 changed blocks (80.73%). Main strict-write capability68 and timezone67 are retained; row-dependent CONV now requires69, with version68 fallback verified through the real two-CN test. Owning packages and full SCA pass. Fresh CI is running.

Retain main RANK boundary-tie capability at v69. Require v70 consistently for CONV worker placement, destination checks, and receiver validation; verify v69 local fallback, v70 execution, and downgrade rejection.
@aunjgr

aunjgr commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

@XuPeng-SH Updated in afe1a0b after merging newest main. Main now owns MORPC v69 for RANK boundary ties; that implementation is retained, and row-dependent/unsigned CONV requires v70 consistently at placement, actual-destination checks, and receiver validation. The v69 fallback, v70 execution, and post-placement downgrade tests pass, as do full compile/function/plan-protobuf suites and the real two-CN CONV regression. Full repository SCA and pre-push validation pass with zero lint issues. Fresh CI is running.

This remains an independent PR under the agreed main/release-only compatibility contract. Any capability landing later must merge the then-current main and allocate the next cumulative version; unrelated unmerged PR binaries are not supported deployment peers. Ready for your re-review; your review request is already active. Already-approved reviewers were not re-requested.

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

GPT-6 medium deep review at exact head afe1a0b.

The earlier remote-protocol concern is closed: the main v69 contract is retained and CONV worker placement, send, and receiver validation consistently require v70. I checked the full change, type-domain handling, NULL/mask behavior, local fallback, and remote downgrade paths. The exact-head CI is green; the new two-CN race test is 2.02 seconds. No verified blocker remains.

@mergify mergify Bot added the queued label Sep 14, 2026
@mergify

mergify Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-14 16:46 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged — 2026-09-14 16:47 UTC · at 05051b73fb5ea9c8d02045fcbb6c26a2eebe2d3f · squash

This pull request spent 42 seconds in the queue, including 3 seconds running CI.

Required conditions to merge

@mergify
mergify Bot merged commit 05051b7 into matrixorigin:main Sep 14, 2026
28 of 29 checks passed
@mergify mergify Bot removed the queued label Sep 14, 2026
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
CONV previously required constant INT64 bases and read them only at row zero. Integer columns of other widths and uncast prepared base parameters could fail during binding, while BIGINT columns and row-dependent expressions failed during execution.

Normalize base argument types locally to CONV, preserving the first argument's source domain and retaining UINT64 bases without a narrowing signed cast. Read and validate each row's bases before conversion; NULL and out-of-range bases return NULL for that row, including signed and unsigned extremes. Preserve selection masks, existing numeric-prefix and BIT conversion semantics, and the cached constant-base path.

Retain existing function overload identities. Require MORPC capability 70 for nonconstant or unsigned base execution shapes, probe the selected workers, and keep execution local when capability is unavailable. Recheck the actual destination before sending and validate the encoded expression at the receiver. Previously supported literal INT64 bases do not require the new capability.

Cover typed inputs, integer-width coercion, NULL/invalid/masked rows, SQL and binary prepared statements, actual pipeline serialization, capability downgrade and local fallback, response cleanup, and real two-CN execution. Include a constant-base benchmark to guard the existing hot path.

Approved by: @XuPeng-SH, @aptend
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
CONV previously required constant INT64 bases and read them only at row zero. Integer columns of other widths and uncast prepared base parameters could fail during binding, while BIGINT columns and row-dependent expressions failed during execution.

Normalize base argument types locally to CONV, preserving the first argument's source domain and retaining UINT64 bases without a narrowing signed cast. Read and validate each row's bases before conversion; NULL and out-of-range bases return NULL for that row, including signed and unsigned extremes. Preserve selection masks, existing numeric-prefix and BIT conversion semantics, and the cached constant-base path.

Retain existing function overload identities. Require MORPC capability 70 for nonconstant or unsigned base execution shapes, probe the selected workers, and keep execution local when capability is unavailable. Recheck the actual destination before sending and validate the encoded expression at the receiver. Previously supported literal INT64 bases do not require the new capability.

Cover typed inputs, integer-width coercion, NULL/invalid/masked rows, SQL and binary prepared statements, actual pipeline serialization, capability downgrade and local fallback, response cleanup, and real two-CN execution. Include a constant-base benchmark to guard the existing hot path.

Approved by: @XuPeng-SH, @aptend
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
CONV previously required constant INT64 bases and read them only at row zero. Integer columns of other widths and uncast prepared base parameters could fail during binding, while BIGINT columns and row-dependent expressions failed during execution.

Normalize base argument types locally to CONV, preserving the first argument's source domain and retaining UINT64 bases without a narrowing signed cast. Read and validate each row's bases before conversion; NULL and out-of-range bases return NULL for that row, including signed and unsigned extremes. Preserve selection masks, existing numeric-prefix and BIT conversion semantics, and the cached constant-base path.

Retain existing function overload identities. Require MORPC capability 70 for nonconstant or unsigned base execution shapes, probe the selected workers, and keep execution local when capability is unavailable. Recheck the actual destination before sending and validate the encoded expression at the receiver. Previously supported literal INT64 bases do not require the new capability.

Cover typed inputs, integer-width coercion, NULL/invalid/masked rows, SQL and binary prepared statements, actual pipeline serialization, capability downgrade and local fallback, response cleanup, and real two-CN execution. Include a constant-base benchmark to guard the existing hot path.

Approved by: @XuPeng-SH, @aptend

This branch was previously deployed

1 inactive deployment
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/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Compatibility]: CONV rejects row-dependent base expressions and uncast prepared bases

4 participants