berkaysynnada commented on code in PR #10543: URL: https://github.com/apache/datafusion/pull/10543#discussion_r1611413134
########## datafusion/physical-expr/src/expressions/case.rs: ########## @@ -258,6 +259,10 @@ impl CaseExpr { } } +lazy_static! { Review Comment: In a world where `NoOp`'s are never used, I don't see a reason why this implementation wouldn't work. ``` let expr = if self.expr().is_some() { Some(children[0].clone()) } else { None }; let else_expr = if self.expr().is_some() { Some(children[children.len() - 1].clone()) } else { None }; let branches = match (&expr, &else_expr) { (Some(_), Some(_)) => children[1..children.len() - 1].to_vec(), (Some(_), None) => children[1..children.len()].to_vec(), (None, Some(_)) => children[0..children.len() - 1].to_vec(), (None, None) => children[0..children.len()].to_vec(), }; let mut when_then_expr: Vec<WhenThen> = vec![]; for (prev, next) in branches.into_iter().tuples() { when_then_expr.push((prev, next)); } ``` Of course, `NoOp`s are safer and don't require any assumptions, but I'm just curious about what I might be missing. -- 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