Returns Some(ColOpLit) if the expression is either: 1. `col literal` 2. `literal col` 3. operator is `=` or `!=` Returns None otherwise
(expr: &'a Arc<dyn PhysicalExpr>)
| 392 | /// |
| 393 | /// Returns None otherwise |
| 394 | fn try_new(expr: &'a Arc<dyn PhysicalExpr>) -> Option<Self> { |
| 395 | let binary_expr = expr.downcast_ref::<crate::expressions::BinaryExpr>()?; |
| 396 | |
| 397 | let (left, op, right) = |
| 398 | (binary_expr.left(), binary_expr.op(), binary_expr.right()); |
| 399 | let guarantee = match op { |
| 400 | Operator::Eq => Guarantee::In, |
| 401 | Operator::NotEq => Guarantee::NotIn, |
| 402 | _ => return None, |
| 403 | }; |
| 404 | // col <op> literal |
| 405 | if let (Some(col), Some(lit)) = ( |
| 406 | left.downcast_ref::<crate::expressions::Column>(), |
| 407 | right.downcast_ref::<crate::expressions::Literal>(), |
| 408 | ) { |
| 409 | Some(Self { |
| 410 | col, |
| 411 | guarantee, |
| 412 | lit, |
| 413 | }) |
| 414 | } |
| 415 | // literal <op> col |
| 416 | else if let (Some(lit), Some(col)) = ( |
| 417 | left.downcast_ref::<crate::expressions::Literal>(), |
| 418 | right.downcast_ref::<crate::expressions::Column>(), |
| 419 | ) { |
| 420 | Some(Self { |
| 421 | col, |
| 422 | guarantee, |
| 423 | lit, |
| 424 | }) |
| 425 | } else { |
| 426 | None |
| 427 | } |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | /// Represents a single `col [not]in literal` expression |