Skip to content

Simplify error handling in case.rs #13990

@aweltsch

Description

@aweltsch

Is your feature request related to a problem or challenge?

As part of the review for #13953 @2010YOUY01 brought up that some of the error handling code in datafusion/physical-expr/src/expressions/case.rs can be simplified, due to type checks being performed before evaluation.
This will clean-up and simplify the code a little bit.

Describe the solution you'd like

Replace occurences similar to

            DataFusionError::Context(
                "WHEN expression did not return a BooleanArray".to_string(),
                Box::new(e),
            )

and

        let expr = try_cast(Arc::clone(e), &batch.schema(), return_type.clone())
            .unwrap_or_else(|_| Arc::clone(e));

with code that returns an internal error directly

Describe alternatives you've considered

No response

Additional context

Link to suggestions from the review:

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions