Skip to content

[Subtask]: add numeric resolver and prepared expression context #25751

Closed

Description

@ck89119

Parent Issue

Parent issue: #25705

Detail of Subtask

Introduce an arithmetic-specific numeric type resolver and prepared-expression context propagation for +, -, *, /,
DIV, MOD, and unary +/-.

The resolver must select parameter and result types from typed operands and optional outer context with this precedence:

  1. approximate operand;
  2. decimal operand;
  3. exact outer context;
  4. integer operand;
  5. context-free parameters default to DOUBLE.

Cover explicit casts, literals, read-only column type lookup, nested arithmetic, function-form MOD(), and strict boundaries
that prevent numeric context from leaking into unrelated functions or comparisons.

Describe implementation you've considered

Implement a pure resolver in pkg/sql/plan/function that returns operand coercion and result types. During PREPARE, scan one
continuous arithmetic AST without mutating binder state, then bind the subtree once with the selected parameter type. Keep
non-prepared queries and non-numeric coercion on their existing paths.

Additional information

Acceptance requires table-driven resolver tests, prepared plan tests, ordinary-query regressions, decimal precision/scale
coverage, and no mutation of GROUP BY, projection, or alias bookkeeping during type inspection.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions