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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
alamb opened this issue Apr 21, 2024 · 1 comment · Fixed by #10168

Comments

@alamb
Copy link
Contributor

alamb commented Apr 21, 2024

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)

@Lordworms
Copy link
Contributor

let me do this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants