Skip to content

Fix : UNARY_PLUS operator should convert value to DOUBLE in expected value generation #1209

@JaySoni1

Description

@JaySoni1

Currently, the getExpectedValue method for the UNARY_PLUS operator doesn't properly handle type promotion. In SQL (including Materialize/PostgreSQL), applying the unary + operator on a numeric value promotes it to DOUBLE PRECISION. However, the current implementation simply returns the input value as-is, without performing any conversion. This can lead to mismatches in expected vs. actual results during testing and cause invalid test oracle behavior.

Image

Proposed change
Implement the TODO comment by:

  1. Adding support for type promotion to double precision in the UNARY_PLUS operator's expected value logic
  2. Promoting the operand to a double using expectedValue.asDouble()
  3. Creating and returning a MaterializeConstant using the promoted double value
  4. Ensuring the UNARY_PLUS operator’s declared return type reflects this conversion

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions