(
&self,
operand: Option<Box<SQLExpr>>,
conditions: Vec<CaseWhen>,
else_result: Option<Box<SQLExpr>>,
schema: &DFSchema,
planner_context: &mut PlannerCo
| 231 | } |
| 232 | |
| 233 | pub(super) fn sql_case_identifier_to_expr( |
| 234 | &self, |
| 235 | operand: Option<Box<SQLExpr>>, |
| 236 | conditions: Vec<CaseWhen>, |
| 237 | else_result: Option<Box<SQLExpr>>, |
| 238 | schema: &DFSchema, |
| 239 | planner_context: &mut PlannerContext, |
| 240 | ) -> Result<Expr> { |
| 241 | let expr = if let Some(e) = operand { |
| 242 | Some(Box::new(self.sql_expr_to_logical_expr( |
| 243 | *e, |
| 244 | schema, |
| 245 | planner_context, |
| 246 | )?)) |
| 247 | } else { |
| 248 | None |
| 249 | }; |
| 250 | let when_then_expr = conditions |
| 251 | .into_iter() |
| 252 | .map(|e| { |
| 253 | Ok(( |
| 254 | Box::new(self.sql_expr_to_logical_expr( |
| 255 | e.condition, |
| 256 | schema, |
| 257 | planner_context, |
| 258 | )?), |
| 259 | Box::new(self.sql_expr_to_logical_expr( |
| 260 | e.result, |
| 261 | schema, |
| 262 | planner_context, |
| 263 | )?), |
| 264 | )) |
| 265 | }) |
| 266 | .collect::<Result<Vec<_>>>()?; |
| 267 | let else_expr = if let Some(e) = else_result { |
| 268 | Some(Box::new(self.sql_expr_to_logical_expr( |
| 269 | *e, |
| 270 | schema, |
| 271 | planner_context, |
| 272 | )?)) |
| 273 | } else { |
| 274 | None |
| 275 | }; |
| 276 | |
| 277 | Ok(Expr::Case(Case::new(expr, when_then_expr, else_expr))) |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | // (relation, column name) |
no test coverage detected