Skip to content

VerifyError: Bad type on operand stack in CASE with mixed numeric types #27608

@mrigger

Description

@mrigger

Reproducer

Tested on Presto 0.297 (Docker image prestodb/presto:latest, digest sha256:7da6d257a4c879f61b5010feca9d73ff70b069935505edb2ecff435cbe486bf9).

CREATE TABLE t0(c0 DOUBLE);
INSERT INTO t0 VALUES (1.0), (2.0), (3.0);

SELECT CASE 1.0
  WHEN if(MIN(true), -1, -1.0) THEN 1.0
  WHEN coalesce(-c0, 1.0) THEN 1.0
END
FROM t0 GROUP BY c0;

Error

Query failed: java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Reason:
    Type long_2nd (current frame, stack[1]) is not assignable to double_2nd

The issue appears to be in bytecode generation for CASE expressions where if() returns mixed integer/double types — the generated bytecode pushes a long where a double is expected on the operand stack.

Found by SQLancer.

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