◐ Shell
clean mode source ↗

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

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