andygrove commented on code in PR #11534: URL: https://github.com/apache/datafusion/pull/11534#discussion_r1683957851
########## datafusion/physical-expr/src/expressions/case.rs: ########## @@ -86,13 +108,35 @@ impl CaseExpr { when_then_expr: Vec<WhenThen>, else_expr: Option<Arc<dyn PhysicalExpr>>, ) -> Result<Self> { + // normalize null literals to None in the else_expr (this already happens + // during SQL planning, but not necessarily for other use cases) + let else_expr = match &else_expr { + Some(e) => match e.as_any().downcast_ref::<Literal>() { + Some(lit) if lit.value().is_null() => None, + _ => else_expr, + }, + _ => else_expr, + }; + if when_then_expr.is_empty() { exec_err!("There must be at least one WHEN clause") } else { + let eval_method = if expr.is_some() { + EvalMethod::WithExpression + } else if when_then_expr.len() == 1 Review Comment: I added more comments to explain the rationale and what is safe or not -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org