Skip to content

COALESCE does not perform lazy evaluation (unlike Spark) #2233

@coderfender

Description

@coderfender

Describe the bug

Spark's coalesce operation performs lazy evaluation from left to right and returns the first non null value . In case of comet, the expressions are evaluated in parallel and throw an error in case one of them fails due to an exception (Example : Divide by Zero , Arithmetic Overflow) .

Steps to reproduce

A simple select coalesce(100, 1/0) from tbl should be able to reproduce the error . Comet will throw a divide by zero exception while spark returns 100

Expected behavior

Match Spark's behavior i.e lazy evaluation

Additional context

Idea is to convert coalesce into a case expression to lazily evaluate expressions from left to right and return first non NULL value .

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions