Skip to content

[Bug]: YEAR-to-BIT cast bypasses old-worker expression capability checks #29499

Closed

Description

@XuPeng-SH

Origin and scope

Follow-up from the independent review of #29462 at 386c1434232af5ccf153b7c2d23e1240be90d021, compared with base b06ff850d4c54af2aeb920136f6e39d6b88f940b. Tracked separately at the maintainer's request for issues below the main query-regression severity.

Confirmed problem

The PR adds the YEAR → BIT execution case in yearToOthers. The base implementation has no such case and returns unsupported cast from year to BIT.

The existing expression capability mechanism does not recognize this new execution signature. A focused white-box test at the reviewed head:

  1. Binds cast from a YEAR column expression to a BIT(64) target through BindFuncExprImplByPlanExpr.
  2. Calls RequiredRemoteExpressionFeatures: every feature is false.
  3. Calls RequiredPersistedExpressionProtocolVersion: returns 0.
  4. Uses the existing expressionProtocolTestCompile fixture, places that expression in a remote projection, sets the mocked destination version to MORPCVersion100, and calls encodeRemoteScope: succeeds, rather than rejecting the unsupported destination.

Thus a current planner can transmit a valid new expression to an old worker that cannot execute it. The current-version stored-procedure regression test passing does not prove mixed-version compatibility. The expression floor also fails to identify the new capability for persisted expressions.

Impact and evidence boundary

Mixed-version execution can fail for this newly supported cast. This is a compatibility gap, not demonstrated data corruption. The send-path result above was executed in a white-box test; an actual mixed-version cluster was not run. The old executor's missing implementation was verified against the exact base. No claim is made that every ordinary query selects a remote projection.

Minimal fix direction

Prefer lowering through already supported numeric casts if their YEAR/BIT semantics can be proven equivalent. Otherwise extend the existing expression capability mechanism, including placement, send recheck, receive validation and persisted-expression floor. Do not introduce a second version registry or special execution route.

Acceptance

  • A YEAR-column-to-BIT expression cannot reach an unsupported worker; supported workers still execute it.
  • The persisted-expression floor reflects any genuinely new execution requirement, or lowering removes that requirement.
  • Cover NULL, representative YEAR values and BIT width boundaries with compact semantic tests.
  • Exercise old/new destination capability using existing protocol fixtures; include a positive current-version control.
  • Preserve the stored-procedure regression fixed by fix: restore prepared TPCC filter selectivity with per-binding proof #29462.

Activity

  1. self-assigned this
    on Sep 29, 2026
  2. added
    kind/bug
    severity/s0
    on Sep 29, 2026
  3. XuPeng-SH commented on Sep 29, 2026

    @XuPeng-SH
    ContributorAuthor

    Fixed by PR #29462 commit 95e565b. CAST(YEAR AS BIT) now requires the existing MORPC v101 expression contract for persisted plans, placement, send-time destination validation and receive-time validation. Local protocol tests covered v100 rejection, v101 acceptance and a non-YEAR CAST control; plan, compile, pb/plan and function packages passed. A real mixed-version cluster was not rerun. Commit-bound review: #29462 (review).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions