Skip to content

Regression: eager evaluation of expressions inside CASE conditional expression #15384

@findepi

Description

@findepi

Describe the bug

CASE sometimes eagerly evaluates the "then" or "else" branches.

To Reproduce

SELECT v, CASE WHEN v < 0 THEN 1/0 ELSE 1 END
FROM (VALUES (1), (2)) t(v)

Expected behavior

In DataFusion 44 this query run successfully

> SELECT v, CASE WHEN v < 0 THEN 1/0 ELSE 1 END
FROM (VALUES (1), (2)) t(v);
+---+---------------------------------------------------------------------+
| v | CASE WHEN t.v < Int64(0) THEN Int64(1) / Int64(0) ELSE Int64(1) END |
+---+---------------------------------------------------------------------+
| 1 | 1                                                                   |
| 2 | 1                                                                   |
+---+---------------------------------------------------------------------+
2 row(s) fetched.

Additional context

45.0.0 is the first version affected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingregressionSomething that used to work no longer does

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions