Skip to content

Adding the new API is_short_circuits()(default to false, when need set to true) to ScalarUDF and ScalarUDFImpl might be a good way to do this because users may want to define their own short-circuit functions. #10162

@alamb

Description

@alamb

Is your feature request related to a problem or challenge?

As part of consolidating ScalarUDFs in #10098, @Omega359 and @haohuaijin noted that there is still a special case for coalesce. Specifically, #10098 (comment)_

Describe the solution you'd like

          Adding the new API `is_short_circuits()`(default to false, when need set to true) to `ScalarUDF` and `ScalarUDFImpl` might be a good way to do this because users may want to define their own short-circuit functions.

So that would me add a function to ScalarUDFImpl like the following (and remove the check for "coalsce" in the code)

trait ScalarUDFImpl {
..
/// Returns true if some of this `exprs` subexpressions may not be evaluated
/// and thus any side effects (like divide by zero) may not be encountered
/// Setting this to true prevents certain optimizations such as common subexpression elimination
fn short_circuits() -> bool {
  false
}

Then return true in the implementation of Coalsce

Originally posted by @haohuaijin in #10098 (comment)

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